Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r83114 - in branches/release: boost libs/conversion/doc libs/conversion/test
From: antoshkka_at_[hidden]
Date: 2013-02-24 03:31:18


Author: apolukhin
Date: 2013-02-24 03:31:17 EST (Sun, 24 Feb 2013)
New Revision: 83114
URL: http://svn.boost.org/trac/boost/changeset/83114

Log:
Merge from trunk:
* Silence some buggy VS warnings (fixes #7949)
* Fix -Wconversion warnings (fixes #2558)
* Added support for int128 conversions (fixes #7909)
Text files modified:
   branches/release/boost/lexical_cast.hpp | 69 ++++++++++++++++----
   branches/release/libs/conversion/doc/lexical_cast.qbk | 132 +++++++++++++++++++++++++++++++++++++++
   branches/release/libs/conversion/test/lexical_cast_integral_types_test.cpp | 76 ++++++++++++++++++++--
   branches/release/libs/conversion/test/lexical_cast_vc8_bug_test.cpp | 4
   4 files changed, 253 insertions(+), 28 deletions(-)

Modified: branches/release/boost/lexical_cast.hpp
==============================================================================
--- branches/release/boost/lexical_cast.hpp (original)
+++ branches/release/boost/lexical_cast.hpp 2013-02-24 03:31:17 EST (Sun, 24 Feb 2013)
@@ -69,6 +69,11 @@
     throw_exception(bad_lexical_cast(typeid(Source), typeid(Target)))
 #endif
 
+#if (defined(BOOST_LCAST_HAS_INT128) && !defined(__GNUC__)) || GCC_VERSION > 40700
+#define BOOST_LCAST_HAS_INT128
+#endif
+
+
 namespace boost
 {
     // exception used to indicate runtime lexical_cast failure
@@ -310,6 +315,11 @@
> {};
 #endif
 
+#ifdef BOOST_LCAST_HAS_INT128
+ template <> struct stream_char_common< boost::int128_type >: public boost::mpl::identity< char > {};
+ template <> struct stream_char_common< boost::uint128_type >: public boost::mpl::identity< char > {};
+#endif
+
 #if !defined(BOOST_LCAST_NO_WCHAR_T) && defined(BOOST_NO_INTRINSIC_WCHAR_T)
         template <>
         struct stream_char_common< wchar_t >
@@ -602,6 +612,10 @@
         BOOST_LCAST_DEF(unsigned __int64)
         BOOST_LCAST_DEF( __int64)
 #endif
+#ifdef BOOST_LCAST_HAS_INT128
+ BOOST_LCAST_DEF(boost::int128_type)
+ BOOST_LCAST_DEF(boost::uint128_type)
+#endif
 
 #undef BOOST_LCAST_DEF
 
@@ -824,7 +838,7 @@
                             if(group < grouping_size)
                             {
                                 char const grp_size = grouping[group];
- last_grp_size = grp_size <= 0 ? CHAR_MAX : grp_size;
+ last_grp_size = grp_size <= 0 ? static_cast<char>(CHAR_MAX) : grp_size;
                             }
 
                             left = last_grp_size;
@@ -872,7 +886,7 @@
 
             if (begin > end || *end < czero || *end >= czero + 10)
                 return false;
- value = *end - czero;
+ value = static_cast<T>(*end - czero);
             --end;
             T multiplier = 1;
             bool multiplier_overflowed = false;
@@ -892,17 +906,17 @@
                 {
                     unsigned char current_grouping = 0;
                     CharT const thousands_sep = np.thousands_sep();
- char remained = grouping[current_grouping] - 1;
+ char remained = static_cast<char>(grouping[current_grouping] - 1);
                     bool shall_we_return = true;
 
                     for(;end>=begin; --end)
                     {
                         if (remained) {
- T const multiplier_10 = multiplier * 10;
+ T const multiplier_10 = static_cast<T>(multiplier * 10);
                             if (multiplier_10 / 10 != multiplier) multiplier_overflowed = true;
 
- T const dig_value = *end - czero;
- T const new_sub_value = multiplier_10 * dig_value;
+ T const dig_value = static_cast<T>(*end - czero);
+ T const new_sub_value = static_cast<T>(multiplier_10 * dig_value);
 
                             if (*end < czero || *end >= czero + 10
                                     /* detecting overflow */
@@ -912,8 +926,8 @@
                                     )
                                 return false;
 
- value += new_sub_value;
- multiplier *= 10;
+ value = static_cast<T>(value + new_sub_value);
+ multiplier = static_cast<T>(multiplier * 10);
                             --remained;
                         } else {
                             if ( !Traits::eq(*end, thousands_sep) ) //|| begin == end ) return false;
@@ -946,11 +960,11 @@
             {
                 while ( begin <= end )
                 {
- T const multiplier_10 = multiplier * 10;
+ T const multiplier_10 = static_cast<T>(multiplier * 10);
                     if (multiplier_10 / 10 != multiplier) multiplier_overflowed = true;
 
- T const dig_value = *end - czero;
- T const new_sub_value = multiplier_10 * dig_value;
+ T const dig_value = static_cast<T>(*end - czero);
+ T const new_sub_value = static_cast<T>(multiplier_10 * dig_value);
 
                     if (*end < czero || *end >= czero + 10
                             /* detecting overflow */
@@ -960,8 +974,8 @@
                             )
                         return false;
 
- value += new_sub_value;
- multiplier *= 10;
+ value = static_cast<T>(value + new_sub_value);
+ multiplier = static_cast<T>(multiplier * 10);
                     --end;
                 }
             }
@@ -1142,6 +1156,12 @@
 
     namespace detail // lcast_ret_float
     {
+
+// Silence buggy MS warnings like C4244: '+=' : conversion from 'int' to 'unsigned short', possible loss of data
+#if defined(_MSC_VER) && (_MSC_VER == 1400)
+# pragma warning(push)
+# pragma warning(disable:4244)
+#endif
         template <class T>
         struct mantissa_holder_type
         {
@@ -1178,7 +1198,7 @@
                     : np.grouping()
             );
             std::string::size_type const grouping_size = grouping.size();
- CharT const thousands_sep = grouping_size ? np.thousands_sep() : 0;
+ CharT const thousands_sep = static_cast<CharT>(grouping_size ? np.thousands_sep() : 0);
             CharT const decimal_point = np.decimal_point();
             bool found_grouping = false;
             std::string::size_type last_grouping_pos = grouping_size - 1;
@@ -1383,6 +1403,10 @@
 
             return true;
         }
+// Unsilence buggy MS warnings like C4244: '+=' : conversion from 'int' to 'unsigned short', possible loss of data
+#if defined(_MSC_VER) && (_MSC_VER == 1400)
+# pragma warning(pop)
+#endif
     }
 
     namespace detail // stl_buf_unlocker
@@ -1723,6 +1747,12 @@
             bool operator<<(unsigned __int64 n) { start = lcast_put_unsigned<Traits>(n, finish); return true; }
             bool operator<<( __int64 n) { return shl_signed(n); }
 #endif
+
+#ifdef BOOST_LCAST_HAS_INT128
+ bool operator<<(const boost::uint128_type& n) { start = lcast_put_unsigned<Traits>(n, finish); return true; }
+ bool operator<<(const boost::int128_type& n) { return shl_signed(n); }
+#endif
+
             bool operator<<(float val) { return shl_real_type(val, start, finish); }
             bool operator<<(double val) { return shl_real_type(val, start, finish); }
             bool operator<<(long double val) {
@@ -1916,7 +1946,7 @@
             }
 
 /************************************ OPERATORS >> ( ... ) ********************************/
- public:
+ public:
             bool operator>>(unsigned short& output) { return shr_unsigned(output); }
             bool operator>>(unsigned int& output) { return shr_unsigned(output); }
             bool operator>>(unsigned long int& output) { return shr_unsigned(output); }
@@ -1930,6 +1960,12 @@
             bool operator>>(unsigned __int64& output) { return shr_unsigned(output); }
             bool operator>>(__int64& output) { return shr_signed(output); }
 #endif
+
+#ifdef BOOST_LCAST_HAS_INT128
+ bool operator>>(boost::uint128_type& output) { return shr_unsigned(output); }
+ bool operator>>(boost::int128_type& output) { return shr_signed(output); }
+#endif
+
             bool operator>>(char& output) { return shr_xchar(output); }
             bool operator>>(unsigned char& output) { return shr_xchar(output); }
             bool operator>>(signed char& output) { return shr_xchar(output); }
@@ -2324,7 +2360,7 @@
> converter_t;
 
                 return (
- arg < 0 ? 0u - converter_t::convert(0u - arg) : converter_t::convert(arg)
+ arg < 0 ? static_cast<Target>(0u - converter_t::convert(0u - arg)) : converter_t::convert(arg)
                 );
             }
         };
@@ -2563,6 +2599,7 @@
 
 #undef BOOST_LCAST_THROW_BAD_CAST
 #undef BOOST_LCAST_NO_WCHAR_T
+#undef BOOST_LCAST_HAS_INT128
 
 #endif // BOOST_LEXICAL_CAST_INCLUDED
 

Modified: branches/release/libs/conversion/doc/lexical_cast.qbk
==============================================================================
--- branches/release/libs/conversion/doc/lexical_cast.qbk (original)
+++ branches/release/libs/conversion/doc/lexical_cast.qbk 2013-02-24 03:31:17 EST (Sun, 24 Feb 2013)
@@ -3,7 +3,7 @@
     [version 1.0]
     [copyright 2000-2005 Kevlin Henney]
     [copyright 2006-2010 Alexander Nasonov]
- [copyright 2011-2012 Antony Polukhin]
+ [copyright 2011-2013 Antony Polukhin]
     [category String and text processing]
     [category Miscellaneous]
     [license
@@ -276,6 +276,10 @@
 
 [section Changes]
 
+* [*boost 1.54.0 :]
+
+ * Added code to convert boost::int128_type and boost::uint128_type (requires GCC 4.7 or higher).
+
 * [*boost 1.53.0 :]
 
     * Much better input and output streams detection for user defined types.
@@ -880,6 +884,132 @@
 ]
 [endsect]
 
+[section Microsoft Visual C++ version 11.0]
+[table:id Performance Table ( Microsoft Visual C++ version 11.0)
+[[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]]
+ [[ string->char ][ !!! *<1* !!! ][ 43 ][ 17 ][ 7 ]]
+ [[ string->signed char ][ !!! *<1* !!! ][ 43 ][ 17 ][ 8 ]]
+ [[ string->unsigned char ][ !!! *<1* !!! ][ 42 ][ 17 ][ 8 ]]
+ [[ string->int ][ !!! *8* !!! ][ 71 ][ 49 ][ 10 ]]
+ [[ string->short ][ !!! *8* !!! ][ 72 ][ 47 ][ 10 ]]
+ [[ string->long int ][ !!! *8* !!! ][ 71 ][ 47 ][ 10 ]]
+ [[ string->long long ][ !!! *8* !!! ][ 71 ][ 47 ][ 10 ]]
+ [[ string->unsigned int ][ !!! *8* !!! ][ 72 ][ 46 ][ 10 ]]
+ [[ string->unsigned short ][ !!! *8* !!! ][ 71 ][ 47 ][ 10 ]]
+ [[ string->unsigned long int ][ !!! *8* !!! ][ 70 ][ 45 ][ 10 ]]
+ [[ string->unsigned long long ][ !!! *8* !!! ][ 70 ][ 46 ][ 10 ]]
+ [[ string->float ][ !!! *14* !!! ][ 586 ][ 559 ][ 37 ]]
+ [[ string->double ][ 601 ][ 618 ][ 592 ][ !!! *37* !!! ]]
+ [[ string->long double ][ 629 ][ 645 ][ 618 ][ !!! *37* !!! ]]
+ [[ string->array<char, 50> ][ !!! *<1* !!! ][ 52 ][ 28 ][ 11 ]]
+ [[ string->string ][ !!! *1* !!! ][ 59 ][ 34 ][ --- ]]
+ [[ string->container::string ][ !!! *2* !!! ][ 54 ][ 31 ][ --- ]]
+ [[ string->char ][ !!! *2* !!! ][ 50 ][ 24 ][ 9 ]]
+ [[ string->signed char ][ !!! *2* !!! ][ 50 ][ 24 ][ 13 ]]
+ [[ string->unsigned char ][ !!! *2* !!! ][ 50 ][ 24 ][ 13 ]]
+ [[ int->string ][ !!! *9* !!! ][ 86 ][ 59 ][ 13 ]]
+ [[ short->string ][ !!! *9* !!! ][ 86 ][ 59 ][ 13 ]]
+ [[ long int->string ][ !!! *9* !!! ][ 87 ][ 59 ][ 13 ]]
+ [[ long long->string ][ !!! *9* !!! ][ 88 ][ 62 ][ 13 ]]
+ [[ unsigned int->string ][ !!! *9* !!! ][ 87 ][ 60 ][ 13 ]]
+ [[ unsigned short->string ][ !!! *9* !!! ][ 91 ][ 63 ][ 13 ]]
+ [[ unsigned long int->string ][ !!! *9* !!! ][ 91 ][ 62 ][ 13 ]]
+ [[ unsigned long long->string ][ !!! *9* !!! ][ 88 ][ 60 ][ 13 ]]
+ [[ float->string ][ 73 ][ 167 ][ 137 ][ !!! *56* !!! ]]
+ [[ double->string ][ 77 ][ 176 ][ 144 ][ !!! *64* !!! ]]
+ [[ long double->string ][ 79 ][ 175 ][ 143 ][ !!! *63* !!! ]]
+ [[ char*->char ][ !!! *<1* !!! ][ 43 ][ 17 ][ 7 ]]
+ [[ char*->signed char ][ !!! *<1* !!! ][ 43 ][ 17 ][ 8 ]]
+ [[ char*->unsigned char ][ !!! *<1* !!! ][ 44 ][ 17 ][ 8 ]]
+ [[ char*->int ][ !!! *8* !!! ][ 70 ][ 47 ][ 10 ]]
+ [[ char*->short ][ !!! *8* !!! ][ 72 ][ 48 ][ 10 ]]
+ [[ char*->long int ][ !!! *8* !!! ][ 72 ][ 47 ][ 10 ]]
+ [[ char*->long long ][ !!! *8* !!! ][ 71 ][ 47 ][ 10 ]]
+ [[ char*->unsigned int ][ !!! *8* !!! ][ 72 ][ 46 ][ 10 ]]
+ [[ char*->unsigned short ][ !!! *8* !!! ][ 72 ][ 47 ][ 10 ]]
+ [[ char*->unsigned long int ][ !!! *8* !!! ][ 70 ][ 46 ][ 10 ]]
+ [[ char*->unsigned long long ][ !!! *8* !!! ][ 70 ][ 45 ][ 10 ]]
+ [[ char*->float ][ !!! *14* !!! ][ 586 ][ 560 ][ 37 ]]
+ [[ char*->double ][ 598 ][ 617 ][ 597 ][ !!! *40* !!! ]]
+ [[ char*->long double ][ 635 ][ 653 ][ 622 ][ !!! *37* !!! ]]
+ [[ char*->array<char, 50> ][ !!! *1* !!! ][ 53 ][ 28 ][ 11 ]]
+ [[ char*->string ][ !!! *1* !!! ][ 59 ][ 35 ][ --- ]]
+ [[ char*->container::string ][ !!! *3* !!! ][ 54 ][ 30 ][ --- ]]
+ [[ unsigned char*->char ][ !!! *<1* !!! ][ 41 ][ 17 ][ 7 ]]
+ [[ unsigned char*->signed char ][ !!! *<1* !!! ][ 42 ][ 17 ][ 8 ]]
+ [[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 41 ][ 17 ][ 8 ]]
+ [[ unsigned char*->int ][ !!! *8* !!! ][ 72 ][ 47 ][ 10 ]]
+ [[ unsigned char*->short ][ !!! *8* !!! ][ 72 ][ 47 ][ 10 ]]
+ [[ unsigned char*->long int ][ !!! *8* !!! ][ 72 ][ 47 ][ 10 ]]
+ [[ unsigned char*->long long ][ !!! *8* !!! ][ 72 ][ 47 ][ 11 ]]
+ [[ unsigned char*->unsigned int ][ !!! *8* !!! ][ 70 ][ 46 ][ 10 ]]
+ [[ unsigned char*->unsigned short ][ !!! *8* !!! ][ 72 ][ 48 ][ 10 ]]
+ [[ unsigned char*->unsigned long int ][ !!! *8* !!! ][ 71 ][ 46 ][ 10 ]]
+ [[ unsigned char*->unsigned long long ][ !!! *8* !!! ][ 70 ][ 45 ][ 11 ]]
+ [[ unsigned char*->float ][ !!! *14* !!! ][ 589 ][ 564 ][ 38 ]]
+ [[ unsigned char*->double ][ 601 ][ 615 ][ 588 ][ !!! *37* !!! ]]
+ [[ unsigned char*->long double ][ 628 ][ 644 ][ 620 ][ !!! *38* !!! ]]
+ [[ unsigned char*->array<char, 50> ][ !!! *1* !!! ][ 54 ][ 28 ][ 11 ]]
+ [[ unsigned char*->string ][ !!! *2* !!! ][ 59 ][ 36 ][ --- ]]
+ [[ unsigned char*->container::string ][ !!! *3* !!! ][ 54 ][ 30 ][ --- ]]
+ [[ signed char*->char ][ !!! *<1* !!! ][ 41 ][ 17 ][ 7 ]]
+ [[ signed char*->signed char ][ !!! *<1* !!! ][ 43 ][ 17 ][ 8 ]]
+ [[ signed char*->unsigned char ][ !!! *<1* !!! ][ 42 ][ 17 ][ 8 ]]
+ [[ signed char*->int ][ !!! *8* !!! ][ 71 ][ 47 ][ 10 ]]
+ [[ signed char*->short ][ !!! *8* !!! ][ 72 ][ 48 ][ 10 ]]
+ [[ signed char*->long int ][ !!! *8* !!! ][ 71 ][ 47 ][ 10 ]]
+ [[ signed char*->long long ][ !!! *8* !!! ][ 72 ][ 47 ][ 10 ]]
+ [[ signed char*->unsigned int ][ !!! *8* !!! ][ 70 ][ 46 ][ 10 ]]
+ [[ signed char*->unsigned short ][ !!! *8* !!! ][ 72 ][ 47 ][ 10 ]]
+ [[ signed char*->unsigned long int ][ !!! *8* !!! ][ 70 ][ 46 ][ 10 ]]
+ [[ signed char*->unsigned long long ][ !!! *8* !!! ][ 70 ][ 46 ][ 11 ]]
+ [[ signed char*->float ][ !!! *14* !!! ][ 586 ][ 562 ][ 37 ]]
+ [[ signed char*->double ][ 603 ][ 615 ][ 589 ][ !!! *37* !!! ]]
+ [[ signed char*->long double ][ 630 ][ 644 ][ 623 ][ !!! *40* !!! ]]
+ [[ signed char*->array<char, 50> ][ !!! *1* !!! ][ 54 ][ 28 ][ 11 ]]
+ [[ signed char*->string ][ !!! *2* !!! ][ 59 ][ 36 ][ --- ]]
+ [[ signed char*->container::string ][ !!! *3* !!! ][ 54 ][ 30 ][ --- ]]
+ [[ iterator_range<char*>->char ][ !!! *<1* !!! ][ 74 ][ 46 ][ 7 ]]
+ [[ iterator_range<char*>->signed char ][ !!! *<1* !!! ][ 75 ][ 46 ][ 8 ]]
+ [[ iterator_range<char*>->unsigned char ][ !!! *<1* !!! ][ 74 ][ 46 ][ 8 ]]
+ [[ iterator_range<char*>->int ][ !!! *8* !!! ][ 98 ][ 70 ][ 10 ]]
+ [[ iterator_range<char*>->short ][ !!! *8* !!! ][ 103 ][ 72 ][ 10 ]]
+ [[ iterator_range<char*>->long int ][ !!! *8* !!! ][ 111 ][ 71 ][ 10 ]]
+ [[ iterator_range<char*>->long long ][ !!! *8* !!! ][ 98 ][ 70 ][ 10 ]]
+ [[ iterator_range<char*>->unsigned int ][ !!! *7* !!! ][ 103 ][ 76 ][ 10 ]]
+ [[ iterator_range<char*>->unsigned short ][ !!! *8* !!! ][ 104 ][ 75 ][ 10 ]]
+ [[ iterator_range<char*>->unsigned long int ][ !!! *7* !!! ][ 104 ][ 71 ][ 10 ]]
+ [[ iterator_range<char*>->unsigned long long ][ !!! *8* !!! ][ 99 ][ 71 ][ 11 ]]
+ [[ iterator_range<char*>->float ][ !!! *13* !!! ][ 123 ][ 93 ][ 37 ]]
+ [[ iterator_range<char*>->double ][ 603 ][ 111 ][ 82 ][ !!! *38* !!! ]]
+ [[ iterator_range<char*>->long double ][ 629 ][ 116 ][ 83 ][ !!! *38* !!! ]]
+ [[ iterator_range<char*>->array<char, 50> ][ !!! *<1* !!! ][ 82 ][ 52 ][ 11 ]]
+ [[ iterator_range<char*>->string ][ !!! *2* !!! ][ 83 ][ 56 ][ --- ]]
+ [[ iterator_range<char*>->container::string ][ !!! *2* !!! ][ 81 ][ 53 ][ --- ]]
+ [[ array<char, 50>->char ][ !!! *<1* !!! ][ 41 ][ 17 ][ 7 ]]
+ [[ array<char, 50>->signed char ][ !!! *<1* !!! ][ 41 ][ 17 ][ 8 ]]
+ [[ array<char, 50>->unsigned char ][ !!! *<1* !!! ][ 41 ][ 17 ][ 8 ]]
+ [[ array<char, 50>->int ][ !!! *8* !!! ][ 73 ][ 46 ][ 10 ]]
+ [[ array<char, 50>->short ][ !!! *8* !!! ][ 73 ][ 47 ][ 10 ]]
+ [[ array<char, 50>->long int ][ !!! *8* !!! ][ 75 ][ 48 ][ 10 ]]
+ [[ array<char, 50>->long long ][ !!! *8* !!! ][ 73 ][ 48 ][ 11 ]]
+ [[ array<char, 50>->unsigned int ][ !!! *8* !!! ][ 73 ][ 47 ][ 10 ]]
+ [[ array<char, 50>->unsigned short ][ !!! *8* !!! ][ 74 ][ 50 ][ 10 ]]
+ [[ array<char, 50>->unsigned long int ][ !!! *8* !!! ][ 71 ][ 46 ][ 10 ]]
+ [[ array<char, 50>->unsigned long long ][ !!! *8* !!! ][ 70 ][ 47 ][ 11 ]]
+ [[ array<char, 50>->float ][ !!! *14* !!! ][ 586 ][ 567 ][ 37 ]]
+ [[ array<char, 50>->double ][ 599 ][ 624 ][ 590 ][ !!! *37* !!! ]]
+ [[ array<char, 50>->long double ][ 632 ][ 643 ][ 618 ][ !!! *37* !!! ]]
+ [[ array<char, 50>->array<char, 50> ][ !!! *1* !!! ][ 52 ][ 28 ][ 11 ]]
+ [[ array<char, 50>->string ][ !!! *2* !!! ][ 59 ][ 34 ][ --- ]]
+ [[ array<char, 50>->container::string ][ !!! *3* !!! ][ 55 ][ 30 ][ --- ]]
+ [[ int->int ][ !!! *<1* !!! ][ 105 ][ 79 ][ --- ]]
+ [[ float->double ][ !!! *<1* !!! ][ 226 ][ 188 ][ --- ]]
+ [[ char->signed char ][ !!! *<1* !!! ][ 40 ][ 16 ][ --- ]]
+]
+[endsect]
+
+
 
 [/ END of section, generated by performance measuring program ]
 [endsect]

Modified: branches/release/libs/conversion/test/lexical_cast_integral_types_test.cpp
==============================================================================
--- branches/release/libs/conversion/test/lexical_cast_integral_types_test.cpp (original)
+++ branches/release/libs/conversion/test/lexical_cast_integral_types_test.cpp 2013-02-24 03:31:17 EST (Sun, 24 Feb 2013)
@@ -34,6 +34,7 @@
 #include <boost/test/floating_point_comparison.hpp>
 
 #include <boost/type_traits/integral_promotion.hpp>
+#include <boost/type_traits/make_unsigned.hpp>
 #include <string>
 #include <vector>
 #include <memory>
@@ -47,6 +48,10 @@
 #define BOOST_LCAST_NO_WCHAR_T
 #endif
 
+#if (defined(BOOST_LCAST_HAS_INT128) && !defined(__GNUC__)) || GCC_VERSION > 40700
+#define BOOST_LCAST_HAS_INT128
+#endif
+
 // Test all 65536 values if true:
 bool const lcast_test_small_integral_types_completely = false;
 
@@ -56,6 +61,8 @@
 
 using namespace boost;
 
+
+
 void test_conversion_from_to_short();
 void test_conversion_from_to_ushort();
 void test_conversion_from_to_int();
@@ -68,6 +75,10 @@
 void test_conversion_from_to_longlong();
 void test_conversion_from_to_ulonglong();
 #endif
+#ifdef BOOST_LCAST_HAS_INT128
+void test_conversion_from_to_int128();
+void test_conversion_from_to_uint128();
+#endif
 void test_integral_conversions_on_min_max();
 
 
@@ -88,6 +99,10 @@
     suite->add(BOOST_TEST_CASE(&test_conversion_from_to_longlong));
     suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ulonglong));
 #endif
+#ifdef BOOST_LCAST_HAS_INT128
+ suite->add(BOOST_TEST_CASE(&test_conversion_from_to_int128));
+ suite->add(BOOST_TEST_CASE(&test_conversion_from_to_uint128));
+#endif
     suite->add(BOOST_TEST_CASE(&test_integral_conversions_on_min_max));
 
     return suite;
@@ -372,7 +387,7 @@
 };
 
 template<class T>
-void test_conversion_from_to_integral()
+void test_conversion_from_to_integral_minimal()
 {
     char const zero = '0';
     signed char const szero = '0';
@@ -438,7 +453,12 @@
         must_owerflow_str += '0';
         must_owerflow_negative_str += '0';
     }
+}
 
+template<class T>
+void test_conversion_from_to_integral()
+{
+ test_conversion_from_to_integral_minimal<T>();
     typedef std::numpunct<char> numpunct;
 
     restore_oldloc guard;
@@ -536,19 +556,57 @@
 
 #endif
 
+
+#ifdef BOOST_LCAST_HAS_INT128
+void test_conversion_from_to_int128()
+{
+ test_conversion_from_to_integral_minimal<boost::int128_type>();
+}
+
+void test_conversion_from_to_uint128()
+{
+ test_conversion_from_to_integral_minimal<boost::uint128_type>();
+}
+#endif
+
+template <typename SignedT>
+void test_integral_conversions_on_min_max_impl()
+{
+ typedef SignedT signed_t;
+ typedef BOOST_DEDUCED_TYPENAME boost::make_unsigned<signed_t>::type unsigned_t;
+
+ typedef std::numeric_limits<signed_t> s_limits;
+ typedef std::numeric_limits<unsigned_t> uns_limits;
+
+ BOOST_CHECK_EQUAL(lexical_cast<unsigned_t>((uns_limits::max)()), (uns_limits::max)());
+ BOOST_CHECK_EQUAL(lexical_cast<unsigned_t>((uns_limits::min)()), (uns_limits::min)());
+
+ BOOST_CHECK_EQUAL(lexical_cast<signed_t>((s_limits::max)()), (s_limits::max)());
+ BOOST_CHECK_EQUAL(lexical_cast<signed_t>((uns_limits::min)()), static_cast<signed_t>((uns_limits::min)()));
+
+ BOOST_CHECK_EQUAL(lexical_cast<unsigned_t>((s_limits::max)()), static_cast<unsigned_t>((s_limits::max)()));
+ BOOST_CHECK_EQUAL(lexical_cast<unsigned_t>((s_limits::min)()), static_cast<unsigned_t>((s_limits::min)()));
+}
+
 void test_integral_conversions_on_min_max()
 {
- typedef std::numeric_limits<int> int_limits;
- typedef std::numeric_limits<unsigned int> uint_limits;
+ test_integral_conversions_on_min_max_impl<int>();
+ test_integral_conversions_on_min_max_impl<short>();
 
- BOOST_CHECK_EQUAL(lexical_cast<unsigned int>((uint_limits::max)()), (uint_limits::max)());
- BOOST_CHECK_EQUAL(lexical_cast<unsigned int>((uint_limits::min)()), (uint_limits::min)());
+#ifdef _MSC_VER
+ test_integral_conversions_on_min_max_impl<long int>();
 
- BOOST_CHECK_EQUAL(lexical_cast<int>((int_limits::max)()), (int_limits::max)());
- BOOST_CHECK_EQUAL(lexical_cast<int>((uint_limits::min)()), static_cast<int>((uint_limits::min)()));
+#if defined(BOOST_HAS_LONG_LONG)
+ test_integral_conversions_on_min_max_impl<boost::long_long_type>();
+#elif defined(BOOST_HAS_MS_INT64)
+ test_integral_conversions_on_min_max_impl<__int64>();
+#endif
+
+#ifdef BOOST_LCAST_HAS_INT128
+ test_integral_conversions_on_min_max_impl<boost::int128_type>();
+#endif
+#endif
 
- BOOST_CHECK_EQUAL(lexical_cast<unsigned int>((int_limits::max)()), static_cast<unsigned int>((int_limits::max)()));
- BOOST_CHECK_EQUAL(lexical_cast<unsigned int>((int_limits::min)()), static_cast<unsigned int>((int_limits::min)()));
 }
 
 

Modified: branches/release/libs/conversion/test/lexical_cast_vc8_bug_test.cpp
==============================================================================
--- branches/release/libs/conversion/test/lexical_cast_vc8_bug_test.cpp (original)
+++ branches/release/libs/conversion/test/lexical_cast_vc8_bug_test.cpp 2013-02-24 03:31:17 EST (Sun, 24 Feb 2013)
@@ -34,7 +34,7 @@
     o << (limits::max)() << zero;
     s = o.str();
     BOOST_CHECK_THROW(lexical_cast<T>(s), bad_lexical_cast);
- s[s.size()-1] += 9; // '0' -> '9'
+ s[s.size()-1] += static_cast<CharT>(9); // '0' -> '9'
     BOOST_CHECK_THROW(lexical_cast<T>(s), bad_lexical_cast);
 
     if(limits::is_signed)
@@ -43,7 +43,7 @@
         o << (limits::min)() << zero;
         s = o.str();
         BOOST_CHECK_THROW(lexical_cast<T>(s), bad_lexical_cast);
- s[s.size()-1] += 9; // '0' -> '9'
+ s[s.size()-1] += static_cast<CharT>(9); // '0' -> '9'
         BOOST_CHECK_THROW(lexical_cast<T>(s), bad_lexical_cast);
     }
 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk