diff --git a/include/boost/cast.hpp b/include/boost/cast.hpp index 2615d18..0018924 100644 --- a/include/boost/cast.hpp +++ b/include/boost/cast.hpp @@ -50,17 +50,6 @@ # include # include -// It has been demonstrated numerous times that MSVC 6.0 fails silently at link -// time if you use a template function which has template parameters that don't -// appear in the function's argument list. -// -// TODO: Add this to config.hpp? -# if defined(BOOST_MSVC) && BOOST_MSVC < 1300 -# define BOOST_EXPLICIT_DEFAULT_TARGET , ::boost::type* = 0 -# else -# define BOOST_EXPLICIT_DEFAULT_TARGET -# endif - namespace boost { // See the documentation for descriptions of how to choose between @@ -73,7 +62,7 @@ namespace boost // section 15.8 exercise 1, page 425. template - inline Target polymorphic_cast(Source* x BOOST_EXPLICIT_DEFAULT_TARGET) + inline Target polymorphic_cast(Source* x) { Target tmp = dynamic_cast(x); if ( tmp == 0 ) throw std::bad_cast(); @@ -92,14 +81,12 @@ namespace boost // Contributed by Dave Abrahams template - inline Target polymorphic_downcast(Source* x BOOST_EXPLICIT_DEFAULT_TARGET) + inline Target polymorphic_downcast(Source* x) { BOOST_ASSERT( dynamic_cast(x) == x ); // detect logic error return static_cast(x); } -# undef BOOST_EXPLICIT_DEFAULT_TARGET - } // namespace boost # include diff --git a/include/boost/implicit_cast.hpp b/include/boost/implicit_cast.hpp old mode 100755 new mode 100644 diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index c954310..5b43501 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -631,12 +631,11 @@ namespace boost { { template inline - BOOST_DEDUCED_TYPENAME boost::make_unsigned::type lcast_to_unsigned(const T value) BOOST_NOEXCEPT - { + BOOST_DEDUCED_TYPENAME boost::make_unsigned::type lcast_to_unsigned(const T value) BOOST_NOEXCEPT { typedef BOOST_DEDUCED_TYPENAME boost::make_unsigned::type result_type; - return static_cast( - value < 0 ? 0u - static_cast(value) : value - ); + return value < 0 + ? static_cast(0u - static_cast(value)) + : static_cast(value); } } @@ -1063,9 +1062,6 @@ namespace boost { CharT const plus = lcast_char_constants::plus; CharT const capital_e = lcast_char_constants::capital_e; CharT const lowercase_e = lcast_char_constants::lowercase_e; - - typedef BOOST_DEDUCED_TYPENAME Traits::int_type int_type; - int_type const zero = Traits::to_int_type(czero); /* Getting the plus/minus sign */ bool const has_minus = Traits::eq(*begin, minus); @@ -1106,7 +1102,7 @@ namespace boost { if (found_decimal) { /* We allow no thousand_separators after decimal point */ - const mantissa_type tmp_sub_value = static_cast(*begin - zero); + const mantissa_type tmp_sub_value = static_cast(*begin - czero); if (Traits::eq(*begin, lowercase_e) || Traits::eq(*begin, capital_e)) break; if ( *begin < czero || *begin >= czero + 10 ) return false; if ( is_mantissa_full @@ -1128,7 +1124,7 @@ namespace boost { /* Checking for mantissa overflow. If overflow will * occur, them we only increase multiplyer */ - const mantissa_type tmp_sub_value = static_cast(*begin - zero); + const mantissa_type tmp_sub_value = static_cast(*begin - czero); if( is_mantissa_full || ((std::numeric_limits::max)() - tmp_sub_value) / 10u < mantissa ) @@ -1224,7 +1220,7 @@ namespace boost { pow_of_10_t exp_pow_of_10 = 0; while (begin != end) { - pow_of_10_t const sub_value = *begin - zero; + pow_of_10_t const sub_value = *begin - czero; if ( *begin < czero || *begin >= czero + 10 || ((std::numeric_limits::max)() - sub_value) / 10 < exp_pow_of_10) @@ -1733,7 +1729,7 @@ namespace boost { } else { utype const comp_val = static_cast((std::numeric_limits::max)()); succeed = succeed && out_tmp<=comp_val; - output = out_tmp; + output = static_cast(out_tmp); } return succeed; } @@ -1804,7 +1800,7 @@ namespace boost { template bool shr_std_array(ArrayT& output) BOOST_NOEXCEPT { using namespace std; - const std::size_t size = finish - start; + const std::size_t size = static_cast(finish - start); if (size > N - 1) { // `-1` because we need to store \0 at the end return false; } diff --git a/test/lexical_cast_integral_types_test.cpp b/test/lexical_cast_integral_types_test.cpp index 4755071..551a349 100644 --- a/test/lexical_cast_integral_types_test.cpp +++ b/test/lexical_cast_integral_types_test.cpp @@ -367,10 +367,36 @@ void test_conversion_from_to_integral_for_locale() BOOST_CHECK( lexical_cast("30000") == static_cast(30000) ); } + test_conversion_from_integral_to_integral(); + + // This is a part of test_conversion_from_integral_to_string('0') method, + // but with BOOST_CHECK_EQUAL instead of BOOST_CHECK. It is required to see + // what is produced by the to_str(t) method in situations when result + // is different. BOOST_CHECK does not work with wchar_t. + typedef std::numeric_limits limits; + T t = (limits::min)(); + BOOST_CHECK_EQUAL(lexical_cast(t), to_str(t)); + test_conversion_from_integral_to_string('0'); test_conversion_from_string_to_integral('0'); #if !defined(BOOST_LCAST_NO_WCHAR_T) + if (lexical_cast(t) != to_str(t)) { + // Something went wrong, and now we are attempting to find and print the + // difference. + std::wstring wstr = to_str(t); + std::string lcast_str = lexical_cast(t); + std::string str; + str.reserve(wstr.size()); + for (std::size_t i = 0; i < wstr.size(); ++i) { + str.push_back(static_cast(wstr[i])); + } + + BOOST_CHECK_EQUAL(lcast_str.length(), lexical_cast(t).length()); + BOOST_CHECK_EQUAL(to_str(t), str); + BOOST_CHECK_EQUAL(lcast_str, str); + } + test_conversion_from_integral_to_string(L'0'); test_conversion_from_string_to_integral(L'0'); #endif