Skip to content

Commit

Permalink
eliminated MACRO for do length by providing both const and non-const …
Browse files Browse the repository at this point in the history
…versions
  • Loading branch information
robertramey committed Dec 13, 2014
1 parent 26cf086 commit 1fef849
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
26 changes: 18 additions & 8 deletions include/boost/detail/utf8_codecvt_facet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ namespace std {
}
#endif

#if defined(_CPPLIB_VER) && (_CPPLIB_VER < 540)
#define BOOST_CODECVT_DO_LENGTH_CONST const
#else
#define BOOST_CODECVT_DO_LENGTH_CONST
#endif

// maximum lenght of a multibyte string
#define MB_LENGTH_MAX 8

Expand Down Expand Up @@ -183,7 +177,7 @@ struct BOOST_UTF8_DECL utf8_codecvt_facet :
// How many char objects can I process to get <= max_limit
// wchar_t objects?
virtual int do_length(
BOOST_CODECVT_DO_LENGTH_CONST std::mbstate_t &,
const std::mbstate_t &,
const char * from,
const char * from_end,
std::size_t max_limit
Expand All @@ -192,7 +186,23 @@ struct BOOST_UTF8_DECL utf8_codecvt_facet :
throw()
#endif
;

virtual int do_length(
std::mbstate_t & s,
const char * from,
const char * from_end,
std::size_t max_limit
) const
#if BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600))
throw()
#endif
{
return do_length(
const_cast<const std::mbstate_t &>(s),
from,
from_end,
max_limit
);
}
// Largest possible value do_length(state,from,from_end,1) could return.
virtual int do_max_length() const BOOST_NOEXCEPT_OR_NOTHROW {
return 6; // largest UTF-8 encoding of a UCS-4 character
Expand Down
2 changes: 1 addition & 1 deletion include/boost/detail/utf8_codecvt_facet.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ std::codecvt_base::result utf8_codecvt_facet::do_out(
// How many char objects can I process to get <= max_limit
// wchar_t objects?
int utf8_codecvt_facet::do_length(
BOOST_CODECVT_DO_LENGTH_CONST std::mbstate_t &,
const std::mbstate_t &,
const char * from,
const char * from_end,
std::size_t max_limit
Expand Down

0 comments on commit 1fef849

Please sign in to comment.