Attempt to add support for lexical conversions of int128 types (refs #7909)

[SVN r82560]
This commit is contained in:
Antony Polukhin
2013-01-20 12:13:31 +00:00
parent 63b680c082
commit 47bef9517f
2 changed files with 61 additions and 2 deletions
+28 -1
View File
@@ -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 @@ namespace boost {
> {};
#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 @@ namespace boost {
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
@@ -1723,6 +1737,12 @@ namespace boost {
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 +1936,7 @@ namespace boost {
}
/************************************ 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 +1950,12 @@ namespace boost {
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); }
@@ -2563,6 +2589,7 @@ namespace boost {
#undef BOOST_LCAST_THROW_BAD_CAST
#undef BOOST_LCAST_NO_WCHAR_T
#undef BOOST_LCAST_HAS_INT128
#endif // BOOST_LEXICAL_CAST_INCLUDED