Patches for Codegear C++ Builder 2009

[SVN r48981]
This commit is contained in:
Nicola Musatti
2008-09-27 08:59:20 +00:00
6 changed files with 453 additions and 198 deletions
+11 -5
View File
@@ -21,7 +21,13 @@
#include <boost/type_traits/is_abstract.hpp>
#endif
#ifdef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
#if defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) || \
(defined(BOOST_MSVC) && (BOOST_MSVC<1310))
#define BOOST_LCAST_NO_COMPILE_TIME_PRECISION
#endif
#ifdef BOOST_LCAST_NO_COMPILE_TIME_PRECISION
#include <boost/assert.hpp>
#else
#include <boost/static_assert.hpp>
@@ -31,7 +37,7 @@ namespace boost { namespace detail {
class lcast_abstract_stub {};
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
#ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION
// Calculate an argument to pass to std::ios_base::precision from
// lexical_cast. See alternative implementation for broken standard
// libraries in lcast_get_precision below. Keep them in sync, please.
@@ -77,9 +83,9 @@ struct lcast_precision
);
BOOST_STATIC_ASSERT(!is_specialized_bin ||
limits::digits + 0UL < ULONG_MAX / 30103UL &&
(limits::digits + 0UL < ULONG_MAX / 30103UL &&
precision_bin > limits::digits10 + 0UL &&
precision_bin <= streamsize_max + 0UL
precision_bin <= streamsize_max + 0UL)
);
BOOST_STATIC_CONSTANT(std::streamsize, value =
@@ -92,7 +98,7 @@ struct lcast_precision
template<class T>
inline std::streamsize lcast_get_precision(T* = 0)
{
#if !defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS)
#ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION
return lcast_precision<T>::value;
#else // Follow lcast_precision algorithm at run-time:
Executable → Regular
View File
+233 -138
View File
@@ -3,7 +3,7 @@
// Boost lexical_cast.hpp header -------------------------------------------//
//
// See http://www.boost.org/ for most recent version including documentation.
// See http://www.boost.org/libs/conversion for documentation.
// See end of this header for rights and permissions.
//
// what: lexical_cast custom keyword cast
@@ -17,17 +17,23 @@
#include <climits>
#include <cstddef>
#include <istream>
#include <locale>
#include <string>
#include <typeinfo>
#include <exception>
#include <boost/config.hpp>
#include <boost/limits.hpp>
#include <boost/mpl/if.hpp>
#include <boost/throw_exception.hpp>
#include <boost/type_traits/is_pointer.hpp>
#include <boost/type_traits/make_unsigned.hpp>
#include <boost/call_traits.hpp>
#include <boost/static_assert.hpp>
#include <boost/detail/lcast_precision.hpp>
#include <boost/detail/workaround.hpp>
#ifndef BOOST_NO_STD_LOCALE
#include <locale>
#endif
#ifdef BOOST_NO_STRINGSTREAM
#include <strstream>
@@ -45,6 +51,12 @@ namespace boost
{
// exception used to indicate runtime lexical_cast failure
class bad_lexical_cast : public std::bad_cast
#if defined(__BORLANDC__) && BOOST_WORKAROUND( __BORLANDC__, < 0x560 )
// under bcc32 5.5.1 bad_cast doesn't derive from exception
, public std::exception
#endif
{
public:
bad_lexical_cast() :
@@ -52,9 +64,9 @@ namespace boost
{
}
bad_lexical_cast(
const std::type_info &source_type,
const std::type_info &target_type) :
source(&source_type), target(&target_type)
const std::type_info &source_type_arg,
const std::type_info &target_type_arg) :
source(&source_type_arg), target(&target_type_arg)
{
}
const std::type_info &source_type() const
@@ -86,6 +98,14 @@ namespace boost
typedef char type;
};
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template<class CharT, class Traits, class Alloc>
struct stream_char< std::basic_string<CharT,Traits,Alloc> >
{
typedef CharT type;
};
#endif
#ifndef DISABLE_WIDE_CHAR_SUPPORT
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
template<>
@@ -107,11 +127,13 @@ namespace boost
typedef wchar_t type;
};
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template<>
struct stream_char<std::wstring>
{
typedef wchar_t type;
};
#endif
#endif
template<typename TargetChar, typename SourceChar>
@@ -127,6 +149,44 @@ namespace boost
};
}
namespace detail // deduce_char_traits template
{
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template<class CharT, class Target, class Source>
struct deduce_char_traits
{
typedef std::char_traits<CharT> type;
};
template<class CharT, class Traits, class Alloc, class Source>
struct deduce_char_traits< CharT
, std::basic_string<CharT,Traits,Alloc>
, Source
>
{
typedef Traits type;
};
template<class CharT, class Target, class Traits, class Alloc>
struct deduce_char_traits< CharT
, Target
, std::basic_string<CharT,Traits,Alloc>
>
{
typedef Traits type;
};
template<class CharT, class Traits, class Alloc1, class Alloc2>
struct deduce_char_traits< CharT
, std::basic_string<CharT,Traits,Alloc1>
, std::basic_string<CharT,Traits,Alloc2>
>
{
typedef Traits type;
};
#endif
}
namespace detail // lcast_src_length
{
// Return max. length of string representation of Source;
@@ -267,14 +327,15 @@ namespace boost
template<class Source>
struct lcast_src_length_integral
{
#if !defined(__BORLANDC__) || __BORLANDC__ >= 0x581
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_STATIC_CONSTANT(std::size_t, value =
std::numeric_limits<Source>::is_signed +
std::numeric_limits<Source>::is_specialized + // == 1
std::numeric_limits<Source>::digits10 * 2
);
#else
BOOST_STATIC_CONSTANT(std::size_t, value = 156); // 256bit integers
BOOST_STATIC_CONSTANT(std::size_t, value = 156);
BOOST_STATIC_ASSERT(sizeof(Source) * CHAR_BIT <= 256);
#endif
};
@@ -307,9 +368,7 @@ namespace boost
#undef BOOST_AUX_LEXICAL_CAST_DEF
#undef BOOST_AUX_LEXICAL_CAST_DEF1
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
// This #if is in sync with lcast_precision
#ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION
// Helper for floating point types.
// -1.23456789e-123456
// ^ sign
@@ -376,7 +435,7 @@ namespace boost
};
#endif // #ifndef DISABLE_WIDE_CHAR_SUPPORT
#endif // #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
#endif // #ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION
}
namespace detail // '0' and '-' constants
@@ -400,14 +459,8 @@ namespace boost
#endif
}
namespace detail // lexical_streambuf and lexical_streambuf_fake
namespace detail // lexical_streambuf_fake
{
template<typename CharT>
class lexical_streambuf : public std::basic_streambuf<CharT>
{
};
template<typename CharT>
struct lexical_streambuf_fake
{
};
@@ -420,61 +473,36 @@ namespace boost
// C4146: unary minus operator applied to unsigned type, result still unsigned
# pragma warning( disable : 4146 )
#endif
inline unsigned int lcast_to_unsigned(int value)
template<class T>
inline
BOOST_DEDUCED_TYPENAME make_unsigned<T>::type lcast_to_unsigned(T value)
{
unsigned int uval = value;
return value < 0 ? -uval : uval;
typedef BOOST_DEDUCED_TYPENAME make_unsigned<T>::type result_type;
result_type uvalue = static_cast<result_type>(value);
return value < 0 ? -uvalue : uvalue;
}
inline unsigned long lcast_to_unsigned(long value)
{
unsigned long uval = value;
return value < 0 ? -uval : uval;
}
#if defined(BOOST_HAS_LONG_LONG)
inline boost::ulong_long_type lcast_to_unsigned(boost::long_long_type v)
{
boost::ulong_long_type uval = v;
return v < 0 ? -uval : uval;
}
#elif defined(BOOST_HAS_MS_INT64)
inline unsigned __int64 lcast_to_unsigned(__int64 value)
{
unsigned __int64 uval = value;
return value < 0 ? -uval : uval;
}
#endif
#if (defined _MSC_VER)
# pragma warning( pop ) // C4146: unary minus operator applied to unsigned type, result still unsigned
# pragma warning( pop )
#endif
}
namespace detail // lcast_put_unsigned
{
// I'd personally put lcast_put_unsigned in .cpp file if not
// boost practice for header-only libraries (Alexander Nasonov).
template<typename T, typename CharT>
template<class Traits, class T, class CharT>
CharT* lcast_put_unsigned(T n, CharT* finish)
{
CharT thousands_sep = 0;
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_STATIC_ASSERT(!std::numeric_limits<T>::is_signed);
#endif
#ifdef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE
char const* grouping = "";
std::size_t const grouping_size = 0;
#else
#ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE
// TODO: use BOOST_NO_STD_LOCALE
std::locale loc;
typedef std::numpunct<CharT> numpunct;
numpunct const& np = BOOST_USE_FACET(numpunct, loc);
std::string const& grouping = np.grouping();
std::string::size_type const grouping_size = grouping.size();
if(grouping_size)
thousands_sep = np.thousands_sep();
#endif
CharT thousands_sep = grouping_size ? np.thousands_sep() : 0;
std::string::size_type group = 0; // current group number
char last_grp_size = grouping[0] <= 0 ? CHAR_MAX : grouping[0];
// a) Since grouping is const, grouping[grouping.size()] returns 0.
@@ -485,9 +513,15 @@ namespace boost
#endif
char left = last_grp_size;
#endif
typedef typename Traits::int_type int_type;
CharT const czero = lcast_char_constants<CharT>::zero;
int_type const zero = Traits::to_int_type(czero);
do
{
#ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE
if(left == 0)
{
++group;
@@ -499,14 +533,15 @@ namespace boost
left = last_grp_size;
--finish;
*finish = thousands_sep;
Traits::assign(*finish, thousands_sep);
}
--left;
#endif
--finish;
int const digit = static_cast<int>(n % 10);
int const cdigit = digit + lcast_char_constants<CharT>::zero;
*finish = static_cast<char>(cdigit);
int_type const digit = static_cast<int_type>(n % 10U);
Traits::assign(*finish, Traits::to_char_type(zero + digit));
n /= 10;
} while(n);
@@ -516,7 +551,7 @@ namespace boost
namespace detail // stream wrapper for handling lexical conversions
{
template<typename Target, typename Source>
template<typename Target, typename Source, typename Traits>
class lexical_stream
{
private:
@@ -524,6 +559,8 @@ namespace boost
typename stream_char<Target>::type,
typename stream_char<Source>::type>::type char_type;
typedef Traits traits_type;
public:
lexical_stream(char_type* = 0, char_type* = 0)
{
@@ -553,9 +590,12 @@ namespace boost
EOF;
#else
std::char_traits<char_type>::eof();
traits_type::eof();
#endif
}
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
bool operator>>(std::string &output)
{
#if defined(BOOST_NO_STRINGSTREAM)
@@ -571,13 +611,29 @@ namespace boost
return true;
}
#endif
#else
bool operator>>(std::basic_string<char_type,traits_type>& output)
{
stream.str().swap(output);
return true;
}
template<class Alloc>
bool operator>>(std::basic_string<char_type,traits_type,Alloc>& out)
{
std::basic_string<char_type,traits_type> str(stream.str());
out.assign(str.begin(), str.end());
return true;
}
#endif
private:
#if defined(BOOST_NO_STRINGSTREAM)
std::strstream stream;
#elif defined(BOOST_NO_STD_LOCALE)
std::stringstream stream;
#else
std::basic_stringstream<char_type> stream;
std::basic_stringstream<char_type,traits_type> stream;
#endif
};
}
@@ -586,7 +642,8 @@ namespace boost
{
// String representation of Source has an upper limit.
template< class CharT // a result of widest_char transformation
, class Base // lexical_streambuf or lexical_streambuf_fake
, class Base // lexical_streambuf_fake or basic_streambuf<CharT>
, class Traits // usually char_traits<CharT>
>
class lexical_stream_limited_src : public Base
{
@@ -600,19 +657,21 @@ namespace boost
static void widen_and_assign(char*p, char ch)
{
*p = ch;
Traits::assign(*p, ch);
}
#ifndef DISABLE_WIDE_CHAR_SUPPORT
static void widen_and_assign(wchar_t* p, char ch)
{
// TODO: use BOOST_NO_STD_LOCALE
std::locale loc;
*p = BOOST_USE_FACET(std::ctype<wchar_t>, loc).widen(ch);
wchar_t w = BOOST_USE_FACET(std::ctype<wchar_t>, loc).widen(ch);
Traits::assign(*p, w);
}
static void widen_and_assign(wchar_t* p, wchar_t ch)
{
*p = ch;
Traits::assign(*p, ch);
}
static void widen_and_assign(char*, wchar_t ch); // undefined
@@ -642,8 +701,8 @@ namespace boost
public: // output
template<class Traits, class Alloc>
bool operator<<(std::basic_string<CharT, Traits, Alloc> const& str)
template<class Alloc>
bool operator<<(std::basic_string<CharT,Traits,Alloc> const& str)
{
start = const_cast<CharT*>(str.data());
finish = start + str.length();
@@ -706,7 +765,7 @@ namespace boost
EOF;
#else
std::char_traits<CharT>::eof();
Traits::eof();
#endif
}
@@ -722,7 +781,7 @@ namespace boost
#endif
#else
template<class Traits, class Alloc>
template<class Alloc>
bool operator>>(std::basic_string<CharT,Traits,Alloc>& str)
{
str.assign(start, finish);
@@ -731,17 +790,21 @@ namespace boost
#endif
};
template<typename CharT, class Base>
inline bool lexical_stream_limited_src<CharT,Base>::operator<<(
template<typename CharT, class Base, class Traits>
inline bool lexical_stream_limited_src<CharT,Base,Traits>::operator<<(
bool value)
{
*start = value + lcast_char_constants<CharT>::zero;
typedef typename Traits::int_type int_type;
CharT const czero = lcast_char_constants<CharT>::zero;
int_type const zero = Traits::to_int_type(czero);
Traits::assign(*start, Traits::to_char_type(zero + value));
finish = start + 1;
return true;
}
template<typename CharT, class Base>
inline bool lexical_stream_limited_src<CharT,Base>::operator<<(char ch)
template<typename CharT, class Base, class Traits>
inline bool lexical_stream_limited_src<CharT,Base,Traits>::operator<<(
char ch)
{
widen_and_assign(start, ch);
finish = start + 1;
@@ -749,8 +812,8 @@ namespace boost
}
#if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T)
template<typename CharT, class Base>
inline bool lexical_stream_limited_src<CharT,Base>::operator<<(
template<typename CharT, class Base, class Traits>
inline bool lexical_stream_limited_src<CharT,Base,Traits>::operator<<(
wchar_t ch)
{
widen_and_assign(start, ch);
@@ -759,140 +822,163 @@ namespace boost
}
#endif
template<typename CharT, class Base>
inline bool lexical_stream_limited_src<CharT,Base>::operator<<(short n)
template<typename CharT, class Base, class Traits>
inline bool lexical_stream_limited_src<CharT,Base,Traits>::operator<<(
short n)
{
start = lcast_put_unsigned(lcast_to_unsigned(n), finish);
start = lcast_put_unsigned<Traits>(lcast_to_unsigned(n), finish);
if(n < 0)
*--start = lcast_char_constants<CharT>::minus;
{
--start;
CharT const minus = lcast_char_constants<CharT>::minus;
Traits::assign(*start, minus);
}
return true;
}
template<typename CharT, class Base>
inline bool lexical_stream_limited_src<CharT,Base>::operator<<(int n)
template<typename CharT, class Base, class Traits>
inline bool lexical_stream_limited_src<CharT,Base,Traits>::operator<<(
int n)
{
start = lcast_put_unsigned(lcast_to_unsigned(n), finish);
start = lcast_put_unsigned<Traits>(lcast_to_unsigned(n), finish);
if(n < 0)
*--start = lcast_char_constants<CharT>::minus;
{
--start;
CharT const minus = lcast_char_constants<CharT>::minus;
Traits::assign(*start, minus);
}
return true;
}
template<typename CharT, class Base>
inline bool lexical_stream_limited_src<CharT,Base>::operator<<(long n)
template<typename CharT, class Base, class Traits>
inline bool lexical_stream_limited_src<CharT,Base,Traits>::operator<<(
long n)
{
start = lcast_put_unsigned(lcast_to_unsigned(n), finish);
start = lcast_put_unsigned<Traits>(lcast_to_unsigned(n), finish);
if(n < 0)
*--start = lcast_char_constants<CharT>::minus;
{
--start;
CharT const minus = lcast_char_constants<CharT>::minus;
Traits::assign(*start, minus);
}
return true;
}
#if defined(BOOST_HAS_LONG_LONG)
template<typename CharT, class Base>
inline bool lexical_stream_limited_src<CharT,Base>::operator<<(
template<typename CharT, class Base, class Traits>
inline bool lexical_stream_limited_src<CharT,Base,Traits>::operator<<(
boost::long_long_type n)
{
start = lcast_put_unsigned(lcast_to_unsigned(n), finish);
start = lcast_put_unsigned<Traits>(lcast_to_unsigned(n), finish);
if(n < 0)
*--start = lcast_char_constants<CharT>::minus;
{
--start;
CharT const minus = lcast_char_constants<CharT>::minus;
Traits::assign(*start, minus);
}
return true;
}
#elif defined(BOOST_HAS_MS_INT64)
template<typename CharT, class Base>
inline bool lexical_stream_limited_src<CharT,Base>::operator<<(
template<typename CharT, class Base, class Traits>
inline bool lexical_stream_limited_src<CharT,Base,Traits>::operator<<(
__int64 n)
{
start = lcast_put_unsigned(lcast_to_unsigned(n), finish);
start = lcast_put_unsigned<Traits>(lcast_to_unsigned(n), finish);
if(n < 0)
*--start = lcast_char_constants<CharT>::minus;
{
--start;
CharT const minus = lcast_char_constants<CharT>::minus;
Traits::assign(*start, minus);
}
return true;
}
#endif
template<typename CharT, class Base>
inline bool lexical_stream_limited_src<CharT,Base>::operator<<(
template<typename CharT, class Base, class Traits>
inline bool lexical_stream_limited_src<CharT,Base,Traits>::operator<<(
unsigned short n)
{
start = lcast_put_unsigned(+n, finish);
start = lcast_put_unsigned<Traits>(n, finish);
return true;
}
template<typename CharT, class Base>
inline bool lexical_stream_limited_src<CharT,Base>::operator<<(
template<typename CharT, class Base, class Traits>
inline bool lexical_stream_limited_src<CharT,Base,Traits>::operator<<(
unsigned int n)
{
start = lcast_put_unsigned(n, finish);
start = lcast_put_unsigned<Traits>(n, finish);
return true;
}
template<typename CharT, class Base>
inline bool lexical_stream_limited_src<CharT,Base>::operator<<(
template<typename CharT, class Base, class Traits>
inline bool lexical_stream_limited_src<CharT,Base,Traits>::operator<<(
unsigned long n)
{
start = lcast_put_unsigned(n, finish);
start = lcast_put_unsigned<Traits>(n, finish);
return true;
}
#if defined(BOOST_HAS_LONG_LONG)
template<typename CharT, class Base>
inline bool lexical_stream_limited_src<CharT,Base>::operator<<(
template<typename CharT, class Base, class Traits>
inline bool lexical_stream_limited_src<CharT,Base,Traits>::operator<<(
boost::ulong_long_type n)
{
start = lcast_put_unsigned(n, finish);
start = lcast_put_unsigned<Traits>(n, finish);
return true;
}
#elif defined(BOOST_HAS_MS_INT64)
template<typename CharT, class Base>
inline bool lexical_stream_limited_src<CharT,Base>::operator<<(
template<typename CharT, class Base, class Traits>
inline bool lexical_stream_limited_src<CharT,Base,Traits>::operator<<(
unsigned __int64 n)
{
start = lcast_put_unsigned(n, finish);
start = lcast_put_unsigned<Traits>(n, finish);
return true;
}
#endif
template<typename CharT, class Base>
inline bool lexical_stream_limited_src<CharT,Base>::operator<<(
template<typename CharT, class Base, class Traits>
inline bool lexical_stream_limited_src<CharT,Base,Traits>::operator<<(
float val)
{
return this->lcast_put(val);
}
template<typename CharT, class Base>
inline bool lexical_stream_limited_src<CharT,Base>::operator<<(
template<typename CharT, class Base, class Traits>
inline bool lexical_stream_limited_src<CharT,Base,Traits>::operator<<(
double val)
{
return this->lcast_put(val);
}
template<typename CharT, class Base>
inline bool lexical_stream_limited_src<CharT,Base>::operator<<(
template<typename CharT, class Base, class Traits>
inline bool lexical_stream_limited_src<CharT,Base,Traits>::operator<<(
long double val)
{
return this->lcast_put(val);
}
template<typename CharT, class Base>
inline bool lexical_stream_limited_src<CharT,Base>::operator<<(
template<typename CharT, class Base, class Traits>
inline bool lexical_stream_limited_src<CharT,Base,Traits>::operator<<(
CharT const* str)
{
start = const_cast<CharT*>(str);
finish = start + std::char_traits<CharT>::length(str);
finish = start + Traits::length(str);
return true;
}
template<typename CharT, class Base>
inline bool lexical_stream_limited_src<CharT,Base>::operator>>(
template<typename CharT, class Base, class Traits>
inline bool lexical_stream_limited_src<CharT,Base,Traits>::operator>>(
CharT& output)
{
bool const ok = (finish - start == 1);
if(ok)
output = *start;
Traits::assign(output, *start);
return ok;
}
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template<typename CharT, class Base>
inline bool lexical_stream_limited_src<CharT,Base>::operator>>(
template<typename CharT, class Base, class Traits>
inline bool lexical_stream_limited_src<CharT,Base,Traits>::operator>>(
std::string& str)
{
str.assign(start, finish);
@@ -900,8 +986,8 @@ namespace boost
}
#ifndef DISABLE_WIDE_CHAR_SUPPORT
template<typename CharT, class Base>
inline bool lexical_stream_limited_src<CharT,Base>::operator>>(
template<typename CharT, class Base, class Traits>
inline bool lexical_stream_limited_src<CharT,Base,Traits>::operator>>(
std::wstring& str)
{
str.assign(start, finish);
@@ -913,7 +999,7 @@ namespace boost
namespace detail // lcast_streambuf_for_source
{
// Returns true if optimized stream wrapper uses ostream for formatting.
// Returns true if optimized stream wrapper needs ostream for writing.
template<class Source>
struct lcast_streambuf_for_source
{
@@ -941,7 +1027,7 @@ namespace boost
namespace detail // lcast_streambuf_for_target
{
// Returns true if optimized stream wrapper use istream for reading.
// Returns true if optimized stream wrapper needs istream for reading.
template<class Target>
struct lcast_streambuf_for_target
{
@@ -1022,17 +1108,20 @@ namespace boost
BOOST_DEDUCED_TYPENAME boost::call_traits<Source>::param_type arg,
CharT* buf, std::size_t src_len)
{
typedef BOOST_DEDUCED_TYPENAME
deduce_char_traits<CharT,Target,Source>::type traits;
typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_c<
lcast_streambuf_for_target<Target>::value ||
lcast_streambuf_for_source<Source>::value
, lexical_streambuf<CharT>
, lexical_streambuf_fake<CharT>
, std::basic_streambuf<CharT>
, lexical_streambuf_fake
>::type base;
BOOST_DEDUCED_TYPENAME boost::mpl::if_c<
Unlimited
, detail::lexical_stream<Target, Source>
, detail::lexical_stream_limited_src<CharT,base>
, detail::lexical_stream<Target,Source,traits>
, detail::lexical_stream_limited_src<CharT,base,traits>
>::type interpreter(buf, buf + src_len);
// The original form, reproduced below, is more elegant
@@ -1079,7 +1168,13 @@ namespace boost
template<typename Target, typename Source>
Target lexical_cast(Source arg)
{
detail::lexical_stream<Target, Source> interpreter;
typedef typename detail::widest_char<
BOOST_DEDUCED_TYPENAME detail::stream_char<Target>::type
, BOOST_DEDUCED_TYPENAME detail::stream_char<Source>::type
>::type char_type;
typedef std::char_traits<char_type> traits;
detail::lexical_stream<Target, Source, traits> interpreter;
Target result;
if(!(interpreter << arg && interpreter >> result))
@@ -1091,7 +1186,7 @@ namespace boost
}
// Copyright Kevlin Henney, 2000-2005.
// Copyright Alexander Nasonov, 2006.
// Copyright Alexander Nasonov, 2006-2007.
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at