forked from boostorg/conversion
Merge lexical_cast and some conversion docs and test from trunk:
* fixed int128 and uint128 conversions (fixes #8790) * fixed warnings from Boost Inspection Report [SVN r85160]
This commit is contained in:
@@ -69,11 +69,6 @@
|
||||
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
|
||||
@@ -316,7 +311,7 @@ namespace boost {
|
||||
> {};
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_LCAST_HAS_INT128
|
||||
#ifdef BOOST_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
|
||||
@@ -613,7 +608,7 @@ namespace boost {
|
||||
BOOST_LCAST_DEF(unsigned __int64)
|
||||
BOOST_LCAST_DEF( __int64)
|
||||
#endif
|
||||
#ifdef BOOST_LCAST_HAS_INT128
|
||||
#ifdef BOOST_HAS_INT128
|
||||
BOOST_LCAST_DEF(boost::int128_type)
|
||||
BOOST_LCAST_DEF(boost::uint128_type)
|
||||
#endif
|
||||
@@ -879,6 +874,15 @@ namespace boost {
|
||||
{
|
||||
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
|
||||
BOOST_STATIC_ASSERT(!std::numeric_limits<T>::is_signed);
|
||||
|
||||
// GCC when used with flag -std=c++0x may not have std::numeric_limits
|
||||
// specializations for __int128 and unsigned __int128 types.
|
||||
// Try compilation with -std=gnu++0x or -std=gnu++11.
|
||||
//
|
||||
// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40856
|
||||
BOOST_STATIC_ASSERT_MSG(std::numeric_limits<T>::is_specialized,
|
||||
"std::numeric_limits are not specialized for integral type passed to boost::lexical_cast"
|
||||
);
|
||||
#endif
|
||||
CharT const czero = lcast_char_constants<CharT>::zero;
|
||||
--end;
|
||||
@@ -1827,7 +1831,7 @@ namespace boost {
|
||||
bool operator<<( __int64 n) { return shl_signed(n); }
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_LCAST_HAS_INT128
|
||||
#ifdef BOOST_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
|
||||
@@ -2039,7 +2043,7 @@ namespace boost {
|
||||
bool operator>>(__int64& output) { return shr_signed(output); }
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_LCAST_HAS_INT128
|
||||
#ifdef BOOST_HAS_INT128
|
||||
bool operator>>(boost::uint128_type& output) { return shr_unsigned(output); }
|
||||
bool operator>>(boost::int128_type& output) { return shr_signed(output); }
|
||||
#endif
|
||||
@@ -2553,7 +2557,7 @@ namespace boost {
|
||||
);
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CHAR16_T
|
||||
#ifndef BOOST_NO_CXX11_CHAR16_T
|
||||
template <typename Target>
|
||||
inline Target lexical_cast(const char16_t* chars, std::size_t count)
|
||||
{
|
||||
@@ -2562,7 +2566,7 @@ namespace boost {
|
||||
);
|
||||
}
|
||||
#endif
|
||||
#ifndef BOOST_NO_CHAR32_T
|
||||
#ifndef BOOST_NO_CXX11_CHAR32_T
|
||||
template <typename Target>
|
||||
inline Target lexical_cast(const char32_t* chars, std::size_t count)
|
||||
{
|
||||
@@ -2719,7 +2723,6 @@ namespace boost {
|
||||
|
||||
#undef BOOST_LCAST_THROW_BAD_CAST
|
||||
#undef BOOST_LCAST_NO_WCHAR_T
|
||||
#undef BOOST_LCAST_HAS_INT128
|
||||
|
||||
#endif // BOOST_LEXICAL_CAST_INCLUDED
|
||||
|
||||
|
||||
Reference in New Issue
Block a user