mirror of
https://github.com/boostorg/conversion.git
synced 2025-08-03 14:34:33 +02:00
Merged revisions 41268-41398 via svnmerge from
https://svn.boost.org/svn/boost/trunk ........ r41270 | dgregor | 2007-11-20 21:50:21 -0800 (Tue, 20 Nov 2007) | 1 line Fixes #1456 ........ r41271 | johnmaddock | 2007-11-21 01:39:00 -0800 (Wed, 21 Nov 2007) | 1 line Added super/subscript styling as per boost-docs mailing list discussion. ........ r41272 | johnmaddock | 2007-11-21 01:46:36 -0800 (Wed, 21 Nov 2007) | 1 line Fix << iostream operator for the NTL bindings. ........ r41273 | anthonyw | 2007-11-21 02:44:22 -0800 (Wed, 21 Nov 2007) | 1 line changed platform split to allow bjam to track includes and check dependencies ........ r41274 | schoepflin | 2007-11-21 03:00:18 -0800 (Wed, 21 Nov 2007) | 2 lines Added myself to the platform maintainers file. ........ r41276 | bgubenko | 2007-11-21 03:43:00 -0800 (Wed, 21 Nov 2007) | 1 line fix typo in the marking of function_types library tests ........ r41277 | johnmaddock | 2007-11-21 04:09:28 -0800 (Wed, 21 Nov 2007) | 1 line Change warning suppression, to suppress warnings for VC8 as well. ........ r41278 | johnmaddock | 2007-11-21 06:03:16 -0800 (Wed, 21 Nov 2007) | 1 line Apply warning fix for VC8 and later only: earlier versions warn about the warning suppression :-( ........ r41279 | schoepflin | 2007-11-21 07:21:53 -0800 (Wed, 21 Nov 2007) | 2 lines Marked function_types failures depending on stdcall as expected on Tru64/CXX. ........ r41280 | igaztanaga | 2007-11-21 08:18:29 -0800 (Wed, 21 Nov 2007) | 1 line Added offset_ptr test ........ r41281 | igaztanaga | 2007-11-21 08:19:19 -0800 (Wed, 21 Nov 2007) | 1 line Fixed offset_ptr issues with volatile values. ........ r41282 | igaztanaga | 2007-11-21 08:39:48 -0800 (Wed, 21 Nov 2007) | 1 line Changed precalculated sqrt(2) values selection to use enable_if. ........ r41284 | igaztanaga | 2007-11-21 09:32:20 -0800 (Wed, 21 Nov 2007) | 1 line Added performance Jamfile to the project ........ r41285 | hkaiser | 2007-11-21 09:53:37 -0800 (Wed, 21 Nov 2007) | 1 line Wave: Fixed #line statements in generated files not to contain Windows paths anymore. ........ r41286 | marshall | 2007-11-21 11:20:15 -0800 (Wed, 21 Nov 2007) | 1 line Bug fixes #284, #836, #991 ........ r41287 | grafik | 2007-11-21 11:29:55 -0800 (Wed, 21 Nov 2007) | 1 line Fix search for Boost.Build so that it only finds the approved version. ........ r41288 | djowel | 2007-11-21 14:24:37 -0800 (Wed, 21 Nov 2007) | 1 line updated the master css ........ r41289 | matias | 2007-11-21 20:55:54 -0800 (Wed, 21 Nov 2007) | 1 line Explicit failure markup for Bimap ........ r41290 | matias | 2007-11-21 21:18:38 -0800 (Wed, 21 Nov 2007) | 1 line remove wrong placed typename ........ r41297 | joaquin | 2007-11-21 23:59:28 -0800 (Wed, 21 Nov 2007) | 1 line included an exe filename modifying rule to avoid interference problems with Vista UAC (fixes #1429) ........ r41299 | djowel | 2007-11-22 00:39:46 -0800 (Thu, 22 Nov 2007) | 1 line bug fix ........ r41300 | schoepflin | 2007-11-22 01:32:15 -0800 (Thu, 22 Nov 2007) | 3 lines Marked failures for kolmogorov_max_flow_test and max_flow_test in the graph library as expected for cxx and acc. ........ r41301 | johnmaddock | 2007-11-22 01:59:38 -0800 (Thu, 22 Nov 2007) | 1 line Added try...catch around TSS initialisation. ........ r41302 | johnmaddock | 2007-11-22 02:38:48 -0800 (Thu, 22 Nov 2007) | 1 line Fixes #501 #1334. ........ r41303 | bgubenko | 2007-11-22 03:33:09 -0800 (Thu, 22 Nov 2007) | 1 line fix typo in r41302 causing validation error ........ r41304 | rogeeff | 2007-11-22 11:44:12 -0800 (Thu, 22 Nov 2007) | 1 line Try to make it work in release build ........ r41305 | rogeeff | 2007-11-22 11:56:58 -0800 (Thu, 22 Nov 2007) | 1 line new file ........ r41308 | rogeeff | 2007-11-22 12:56:07 -0800 (Thu, 22 Nov 2007) | 2 lines negative chars test added some statements added to the online_test ........ r41310 | rogeeff | 2007-11-22 13:57:16 -0800 (Thu, 22 Nov 2007) | 1 line issue with class base test cases addressed ........ r41311 | anthonyw | 2007-11-22 14:01:30 -0800 (Thu, 22 Nov 2007) | 1 line Removed thread::self in favour of allowing interruption through a thread::id; no longer requires DuplicateHandle ........ r41312 | rogeeff | 2007-11-22 14:06:59 -0800 (Thu, 22 Nov 2007) | 1 line comments cleanup ........ r41313 | grafik | 2007-11-22 18:57:42 -0800 (Thu, 22 Nov 2007) | 1 line Produce less regression reports to reduce the cycle time for test reporting. ........ r41314 | grafik | 2007-11-22 18:58:14 -0800 (Thu, 22 Nov 2007) | 1 line Produce less regression reports to reduce the cycle time for test reporting. ........ r41315 | joaquin | 2007-11-22 23:57:15 -0800 (Thu, 22 Nov 2007) | 1 line added .exe suffix missing at rev 41297 ........ r41317 | johnmaddock | 2007-11-23 09:05:25 -0800 (Fri, 23 Nov 2007) | 1 line Remove the log files, we don't need these in SVN Trunk. ........ r41318 | grafik | 2007-11-23 12:43:38 -0800 (Fri, 23 Nov 2007) | 1 line Add --skip-script-download option to run.py to avoid repeated regression script downloads. Thanks to _m_ for the changes. ........ r41319 | bemandawes | 2007-11-23 14:55:48 -0800 (Fri, 23 Nov 2007) | 1 line Add the instructions formerly in the (now deleted) runner sub-directory ........ r41320 | anthonyw | 2007-11-23 15:09:36 -0800 (Fri, 23 Nov 2007) | 1 line Integrate TSS with thread data; test to ensure cleanup done for native threads as well as boost::thread-launched threads now runs for pthread API as well as win32 API ........ r41324 | grafik | 2007-11-23 18:16:50 -0800 (Fri, 23 Nov 2007) | 1 line Allow use of "conditional" to multiply a condition that already has the full condition in it. ........ r41325 | igaztanaga | 2007-11-24 01:44:30 -0800 (Sat, 24 Nov 2007) | 1 line Marked msvc-8.0-wm5 as unusable ........ r41326 | niels_dekker | 2007-11-24 03:51:03 -0800 (Sat, 24 Nov 2007) | 1 line Checked the result of value_init test function, hoping to pinpoint exactly for what particular type T value_initialized<T> might fail, on some platforms ........ r41327 | johnmaddock | 2007-11-24 04:25:25 -0800 (Sat, 24 Nov 2007) | 1 line Apply patches for building regex on WinCE see: http://lists.boost.org/Archives/boost/2007/11/130839.php ........ r41328 | bemandawes | 2007-11-24 05:15:03 -0800 (Sat, 24 Nov 2007) | 1 line Bring required compilers list closer into sync with actual testers and list discussion ........ r41330 | bemandawes | 2007-11-24 06:59:08 -0800 (Sat, 24 Nov 2007) | 1 line Remove mingw plus some compilers no longer being tested from required list ........ r41331 | nasonov | 2007-11-24 07:22:52 -0800 (Sat, 24 Nov 2007) | 1 line minor changes ........ r41333 | bemandawes | 2007-11-24 08:39:30 -0800 (Sat, 24 Nov 2007) | 1 line Change long name inspection to follow ISO 9660:1997, thus replacing all length requirements with a single 207 maximum path length requirement. ........ r41338 | garcia | 2007-11-24 10:19:22 -0800 (Sat, 24 Nov 2007) | 2 lines A bunch of review dates have been added. ........ r41339 | johnmaddock | 2007-11-24 10:34:17 -0800 (Sat, 24 Nov 2007) | 1 line Changed meaning of "at_end" needs copy-constructor fix. ........ r41341 | noel_belcourt | 2007-11-24 11:09:56 -0800 (Sat, 24 Nov 2007) | 6 lines Replace mpi wrappers with native pathscale compilers. Fixed how we invoke f77 (pathf90 -f77). Thanks to Alain Miniussi for reporting this. ........ r41342 | igaztanaga | 2007-11-24 11:47:58 -0800 (Sat, 24 Nov 2007) | 1 line Added workaround for systems without SEM_FAILED and semaphores based on filesystem ........ r41343 | rogeeff | 2007-11-24 11:49:24 -0800 (Sat, 24 Nov 2007) | 5 lines switch to nasic_cstring.hpp instead of fwd header added failed expression to the system error system_error is caught and reported in cpp_main.ipp 64 bit compatibility issue in debug.ipp fixed missing headers in algorithm.hpp added ........ r41344 | davedeakins | 2007-11-24 12:30:50 -0800 (Sat, 24 Nov 2007) | 1 line Define the BOOST_NO_SWPRINTF macro for WinCE. WinCE's CRT does not have a conforming swprintf signature. ........ r41348 | igaztanaga | 2007-11-24 16:55:14 -0800 (Sat, 24 Nov 2007) | 1 line Marked pathscale and vacpp as unusable for Interprocess/Intrusive ........ r41350 | davedeakins | 2007-11-24 20:30:02 -0800 (Sat, 24 Nov 2007) | 1 line A few corrections to the WinCE patches ........ r41352 | dave | 2007-11-25 01:02:01 -0800 (Sun, 25 Nov 2007) | 2 lines Attempt SunPro workaround ........ r41353 | guwi17 | 2007-11-25 05:34:20 -0800 (Sun, 25 Nov 2007) | 6 lines - fix and close #1237 - symmetric resize used wrong internal resize method -- Dese und die folgenden Zeilen werden ignoriert -- M symmetric.hpp ........ r41355 | bemandawes | 2007-11-25 05:56:09 -0800 (Sun, 25 Nov 2007) | 1 line Remove extra ) from prior commit ........ r41356 | danieljames | 2007-11-25 06:10:05 -0800 (Sun, 25 Nov 2007) | 2 lines Deleting the BoostCon* files. Fixes #1256 ........ r41357 | bemandawes | 2007-11-25 07:08:28 -0800 (Sun, 25 Nov 2007) | 1 line clear # 1230, mbstate uninitialized ........ r41358 | igaztanaga | 2007-11-25 07:18:04 -0800 (Sun, 25 Nov 2007) | 1 line Marked intel-linux-8.* as unusable for Interprocess and Intrusive ........ r41359 | johnmaddock | 2007-11-25 07:47:58 -0800 (Sun, 25 Nov 2007) | 1 line Oops, previous commit messed up POSIX timing code, now fixed. ........ r41361 | johnmaddock | 2007-11-25 08:26:36 -0800 (Sun, 25 Nov 2007) | 1 line Redirection file. ........ r41362 | grafik | 2007-11-25 09:06:17 -0800 (Sun, 25 Nov 2007) | 1 line Move buildbot support to sandbox until we decide what to do with it. ........ r41363 | grafik | 2007-11-25 09:12:42 -0800 (Sun, 25 Nov 2007) | 1 line Some cleanup of tools documentation. Add boostbook redir file. Delete duplicate time_string.hpp. Repoint regression instructions to web site. ........ r41364 | johnmaddock | 2007-11-25 09:23:25 -0800 (Sun, 25 Nov 2007) | 1 line Fix date. ........ r41378 | bemandawes | 2007-11-25 11:56:10 -0800 (Sun, 25 Nov 2007) | 1 line remove hp_cxx-71_006_tru64 as required. ........ r41380 | grafik | 2007-11-25 12:10:10 -0800 (Sun, 25 Nov 2007) | 1 line Add --build-type option to root build. Two choices possible at the moment "minimal" and "complete". With minimal as the default we only build the common release variant. The old behavior of building many variants is available with "complete". ........ r41381 | fcacciola | 2007-11-25 12:26:14 -0800 (Sun, 25 Nov 2007) | 1 line Cast to base added to avoid a call to the convertir constructor/assignment (see Tickes 1419 and 1420) ........ r41383 | burbelgruff | 2007-11-25 13:16:46 -0800 (Sun, 25 Nov 2007) | 1 line Revert to old sizeof based solution for retrieving the type from a typeof hack. This is in order to overcome problems with the code analysis module introduced in Visual Studio 2005. ........ r41384 | davedeakins | 2007-11-25 13:53:26 -0800 (Sun, 25 Nov 2007) | 1 line Added a primitive tmpnam function for WinCE (which does not supply any kind of tmpnam in its CRT) ........ r41385 | nasonov | 2007-11-25 14:28:16 -0800 (Sun, 25 Nov 2007) | 3 lines Pass unsigned type to lcast_put_unsigned. ........ r41387 | nasonov | 2007-11-25 15:08:50 -0800 (Sun, 25 Nov 2007) | 2 lines Support for string with non-default char_traits and allocator. ........ r41391 | davedeakins | 2007-11-25 22:36:55 -0800 (Sun, 25 Nov 2007) | 1 line Nearly all test for the intrusive library pass on the MSVC8/WM5 platform. ........ r41394 | joaquin | 2007-11-26 03:52:03 -0800 (Mon, 26 Nov 2007) | 1 line added missing traits template arg to a lexical_stream instantiation ........ r41395 | anthonyw | 2007-11-26 04:17:45 -0800 (Mon, 26 Nov 2007) | 1 line workaround for Borland compiler ........ r41396 | anthonyw | 2007-11-26 05:29:15 -0800 (Mon, 26 Nov 2007) | 1 line Don't compare native_handle_t against 0 --- do appropriate checks in create_native_thread for platforms where pthread_t is not comparable ........ r41397 | joaquin | 2007-11-26 05:48:36 -0800 (Mon, 26 Nov 2007) | 1 line ADL-based swap call moved to an utility function (after mistaken attempt at rev 41220 to solve name-hiding issues) ........ r41398 | anthonyw | 2007-11-26 07:44:07 -0800 (Mon, 26 Nov 2007) | 1 line fixed import/export declarations so new once code works with pthread-win32 ........ [SVN r41399]
This commit is contained in:
@@ -86,6 +86,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 +115,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 +137,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 +315,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
|
||||
};
|
||||
|
||||
@@ -308,8 +357,6 @@ namespace boost
|
||||
#undef BOOST_AUX_LEXICAL_CAST_DEF1
|
||||
|
||||
#ifndef BOOST_LCAST_NO_COMPILE_TIME_PRECISION
|
||||
// This #if is in sync with lcast_precision
|
||||
|
||||
// Helper for floating point types.
|
||||
// -1.23456789e-123456
|
||||
// ^ sign
|
||||
@@ -400,14 +447,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
|
||||
{
|
||||
};
|
||||
@@ -448,17 +489,19 @@ namespace boost
|
||||
#endif
|
||||
|
||||
#if (defined _MSC_VER)
|
||||
# pragma warning( pop ) // C4146: unary minus operator applied to unsigned type, result still unsigned
|
||||
# pragma warning( pop ) // C4146: unary minus operator applied to unsigned type,
|
||||
// result still unsigned
|
||||
#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)
|
||||
{
|
||||
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
|
||||
BOOST_STATIC_ASSERT(!std::numeric_limits<T>::is_signed);
|
||||
#endif
|
||||
CharT thousands_sep = 0;
|
||||
|
||||
#ifdef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE
|
||||
@@ -483,6 +526,9 @@ namespace boost
|
||||
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
|
||||
BOOST_STATIC_ASSERT(std::numeric_limits<T>::digits10 < CHAR_MAX);
|
||||
#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);
|
||||
|
||||
char left = last_grp_size;
|
||||
|
||||
@@ -499,14 +545,13 @@ namespace boost
|
||||
|
||||
left = last_grp_size;
|
||||
--finish;
|
||||
*finish = thousands_sep;
|
||||
Traits::assign(*finish, thousands_sep);
|
||||
}
|
||||
|
||||
--left;
|
||||
--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 +561,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 +569,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 +600,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 +621,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 +652,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 +667,20 @@ 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)
|
||||
{
|
||||
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 +710,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 +774,7 @@ namespace boost
|
||||
|
||||
EOF;
|
||||
#else
|
||||
std::char_traits<CharT>::eof();
|
||||
Traits::eof();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -722,7 +790,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 +799,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 +821,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 +831,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>(lcast_to_unsigned(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 +995,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 +1008,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 +1036,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 +1117,23 @@ namespace boost
|
||||
BOOST_DEDUCED_TYPENAME boost::call_traits<Source>::param_type arg,
|
||||
CharT* buf, std::size_t src_len)
|
||||
{
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
deduce_char_traits<CharT,Target,Source>::type traits;
|
||||
#else
|
||||
typedef std::char_traits<CharT> traits;
|
||||
#endif
|
||||
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 +1180,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 +1198,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
|
||||
|
@@ -24,6 +24,9 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/floating_point_comparison.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
#if defined(BOOST_NO_STRINGSTREAM) || \
|
||||
defined(BOOST_NO_STD_WSTRING) || \
|
||||
defined(BOOST_NO_STD_LOCALE)
|
||||
@@ -35,6 +38,16 @@
|
||||
#define LCAST_TEST_LONGLONG
|
||||
#endif
|
||||
|
||||
template<class CharT>
|
||||
struct my_traits : std::char_traits<CharT>
|
||||
{
|
||||
};
|
||||
|
||||
template<class CharT>
|
||||
struct my_allocator : std::allocator<CharT>
|
||||
{
|
||||
};
|
||||
|
||||
// Test all 65536 values if true:
|
||||
bool const lcast_test_small_integral_types_completely = false;
|
||||
|
||||
@@ -57,15 +70,21 @@ void test_conversion_from_wstring();
|
||||
void test_conversion_to_wstring();
|
||||
void test_bad_lexical_cast();
|
||||
void test_no_whitespace_stripping();
|
||||
void test_conversion_from_short();
|
||||
void test_conversion_from_ushort();
|
||||
void test_conversion_from_int();
|
||||
void test_conversion_from_uint();
|
||||
void test_conversion_from_long();
|
||||
void test_conversion_from_ulong();
|
||||
void test_conversion_from_to_short();
|
||||
void test_conversion_from_to_ushort();
|
||||
void test_conversion_from_to_int();
|
||||
void test_conversion_from_to_uint();
|
||||
void test_conversion_from_to_long();
|
||||
void test_conversion_from_to_ulong();
|
||||
#ifdef LCAST_TEST_LONGLONG
|
||||
void test_conversion_from_longlong();
|
||||
void test_conversion_from_ulonglong();
|
||||
void test_conversion_from_to_longlong();
|
||||
void test_conversion_from_to_ulonglong();
|
||||
#endif
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
void test_traits();
|
||||
void test_wtraits();
|
||||
void test_allocator();
|
||||
void test_wallocator();
|
||||
#endif
|
||||
|
||||
unit_test::test_suite *init_unit_test_suite(int, char *[])
|
||||
@@ -87,15 +106,21 @@ unit_test::test_suite *init_unit_test_suite(int, char *[])
|
||||
#endif
|
||||
suite->add(BOOST_TEST_CASE(test_bad_lexical_cast));
|
||||
suite->add(BOOST_TEST_CASE(test_no_whitespace_stripping));
|
||||
suite->add(BOOST_TEST_CASE(&test_conversion_from_short));
|
||||
suite->add(BOOST_TEST_CASE(&test_conversion_from_ushort));
|
||||
suite->add(BOOST_TEST_CASE(&test_conversion_from_int));
|
||||
suite->add(BOOST_TEST_CASE(&test_conversion_from_uint));
|
||||
suite->add(BOOST_TEST_CASE(&test_conversion_from_ulong));
|
||||
suite->add(BOOST_TEST_CASE(&test_conversion_from_long));
|
||||
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_short));
|
||||
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ushort));
|
||||
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_int));
|
||||
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_uint));
|
||||
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ulong));
|
||||
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_long));
|
||||
#ifdef LCAST_TEST_LONGLONG
|
||||
suite->add(BOOST_TEST_CASE(&test_conversion_from_longlong));
|
||||
suite->add(BOOST_TEST_CASE(&test_conversion_from_ulonglong));
|
||||
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_longlong));
|
||||
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ulonglong));
|
||||
#endif
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
suite->add(BOOST_TEST_CASE(&test_traits));
|
||||
suite->add(BOOST_TEST_CASE(&test_wtraits));
|
||||
suite->add(BOOST_TEST_CASE(&test_allocator));
|
||||
suite->add(BOOST_TEST_CASE(&test_wallocator));
|
||||
#endif
|
||||
|
||||
return suite;
|
||||
@@ -129,10 +154,15 @@ void test_conversion_to_int()
|
||||
BOOST_CHECK_EQUAL(0, lexical_cast<int>('0'));
|
||||
BOOST_CHECK_THROW(lexical_cast<int>('A'), bad_lexical_cast);
|
||||
BOOST_CHECK_EQUAL(1, lexical_cast<int>(1));
|
||||
BOOST_CHECK_EQUAL(1, lexical_cast<int>(1.0));
|
||||
|
||||
BOOST_CHECK_EQUAL(
|
||||
(std::numeric_limits<int>::max)(),
|
||||
lexical_cast<int>((std::numeric_limits<int>::max)()));
|
||||
BOOST_CHECK_EQUAL(1, lexical_cast<int>(1.0));
|
||||
|
||||
BOOST_CHECK_EQUAL(
|
||||
(std::numeric_limits<int>::min)(),
|
||||
lexical_cast<int>((std::numeric_limits<int>::min)()));
|
||||
|
||||
BOOST_CHECK_THROW(lexical_cast<int>(1.23), bad_lexical_cast);
|
||||
|
||||
@@ -407,7 +437,7 @@ void test_conversion_from_integral_to_char(CharT zero)
|
||||
|
||||
BOOST_CHECK_THROW(lexical_cast<CharT>(static_cast<T>(10)), bad_lexical_cast);
|
||||
|
||||
T t = std::numeric_limits<T>::max();
|
||||
T t = (std::numeric_limits<T>::max)();
|
||||
BOOST_CHECK_THROW(lexical_cast<CharT>(t), bad_lexical_cast);
|
||||
}
|
||||
|
||||
@@ -427,10 +457,10 @@ void test_conversion_from_integral_to_integral()
|
||||
BOOST_CHECK(lexical_cast<long>(t) == st);
|
||||
BOOST_CHECK(lexical_cast<unsigned long>(t) == ut);
|
||||
|
||||
t = std::numeric_limits<T>::max();
|
||||
t = (std::numeric_limits<T>::max)();
|
||||
BOOST_CHECK(lexical_cast<T>(t) == t);
|
||||
|
||||
t = std::numeric_limits<T>::min();
|
||||
t = (std::numeric_limits<T>::min)();
|
||||
BOOST_CHECK(lexical_cast<T>(t) == t);
|
||||
}
|
||||
|
||||
@@ -442,19 +472,20 @@ void test_conversion_from_integral_to_string(CharT)
|
||||
|
||||
T t;
|
||||
|
||||
t = limits::min();
|
||||
t = (limits::min)();
|
||||
BOOST_CHECK(lexical_cast<string_type>(t) == to_str<CharT>(t));
|
||||
|
||||
t = limits::max();
|
||||
t = (limits::max)();
|
||||
BOOST_CHECK(lexical_cast<string_type>(t) == to_str<CharT>(t));
|
||||
|
||||
if(limits::digits <= 16 && lcast_test_small_integral_types_completely)
|
||||
for(t = 1 + limits::min(); t != limits::max(); ++t)
|
||||
// min and max have already been tested.
|
||||
for(t = 1 + (limits::min)(); t != (limits::max)(); ++t)
|
||||
BOOST_CHECK(lexical_cast<string_type>(t) == to_str<CharT>(t));
|
||||
else
|
||||
{
|
||||
T const min_val = limits::min();
|
||||
T const max_val = limits::max();
|
||||
T const min_val = (limits::min)();
|
||||
T const max_val = (limits::max)();
|
||||
T const half_max_val = max_val / 2;
|
||||
T const cnt = lcast_integral_test_counter; // to supress warnings
|
||||
unsigned int const counter = cnt < half_max_val ? cnt : half_max_val;
|
||||
@@ -480,20 +511,75 @@ void test_conversion_from_integral_to_string(CharT)
|
||||
T ten_power = 100;
|
||||
for(int e = 2; e <= limits::digits10; ++e, ten_power *= 10)
|
||||
{
|
||||
// I believe that (ten_power + 100) never overflows
|
||||
// ten_power + 100 probably never overflows
|
||||
for(t = ten_power - 100; t != ten_power + 100; ++t)
|
||||
BOOST_CHECK(lexical_cast<string_type>(t) == to_str<CharT>(t));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class CharT>
|
||||
void test_conversion_from_string_to_integral(CharT)
|
||||
{
|
||||
typedef std::numeric_limits<T> limits;
|
||||
|
||||
T t;
|
||||
|
||||
t = (limits::min)();
|
||||
BOOST_CHECK(lexical_cast<T>(to_str<CharT>(t)) == t);
|
||||
|
||||
t = (limits::max)();
|
||||
BOOST_CHECK(lexical_cast<T>(to_str<CharT>(t)) == t);
|
||||
|
||||
if(limits::digits <= 16 && lcast_test_small_integral_types_completely)
|
||||
// min and max have already been tested.
|
||||
for(t = 1 + (limits::min)(); t != (limits::max)(); ++t)
|
||||
BOOST_CHECK(lexical_cast<T>(to_str<CharT>(t)) == t);
|
||||
else
|
||||
{
|
||||
T const min_val = (limits::min)();
|
||||
T const max_val = (limits::max)();
|
||||
T const half_max_val = max_val / 2;
|
||||
T const cnt = lcast_integral_test_counter; // to supress warnings
|
||||
unsigned int const counter = cnt < half_max_val ? cnt : half_max_val;
|
||||
|
||||
unsigned int i;
|
||||
|
||||
// Test values around min:
|
||||
t = min_val;
|
||||
for(i = 0; i < counter; ++i, ++t)
|
||||
BOOST_CHECK(lexical_cast<T>(to_str<CharT>(t)) == t);
|
||||
|
||||
// Test values around max:
|
||||
t = max_val;
|
||||
for(i = 0; i < counter; ++i, --t)
|
||||
BOOST_CHECK(lexical_cast<T>(to_str<CharT>(t)) == t);
|
||||
|
||||
// Test values around zero:
|
||||
if(limits::is_signed)
|
||||
for(t = -counter; t < static_cast<T>(counter); ++t)
|
||||
BOOST_CHECK(lexical_cast<T>(to_str<CharT>(t)) == t);
|
||||
|
||||
// Test values around 100, 1000, 10000, ...
|
||||
T ten_power = 100;
|
||||
for(int e = 2; e <= limits::digits10; ++e, ten_power *= 10)
|
||||
{
|
||||
// ten_power + 100 probably never overflows
|
||||
for(t = ten_power - 100; t != ten_power + 100; ++t)
|
||||
BOOST_CHECK(lexical_cast<T>(to_str<CharT>(t)) == t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void test_conversion_from_integral_for_locale()
|
||||
void test_conversion_from_to_integral_for_locale()
|
||||
{
|
||||
test_conversion_from_integral_to_integral<T>();
|
||||
test_conversion_from_integral_to_string<T>('0');
|
||||
test_conversion_from_string_to_integral<T>('0');
|
||||
#if !defined(DISABLE_WIDE_CHAR_SUPPORT) && !defined(BOOST_NO_INTRINSIC_WCHAR_T)
|
||||
test_conversion_from_integral_to_string<T>(L'0');
|
||||
test_conversion_from_string_to_integral<T>(L'0');
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -504,7 +590,7 @@ struct restore_oldloc
|
||||
};
|
||||
|
||||
template<class T>
|
||||
void test_conversion_from_integral()
|
||||
void test_conversion_from_to_integral()
|
||||
{
|
||||
char const zero = '0';
|
||||
signed char const szero = '0';
|
||||
@@ -517,7 +603,7 @@ void test_conversion_from_integral()
|
||||
test_conversion_from_integral_to_char<T>(wzero);
|
||||
#endif
|
||||
|
||||
// test_conversion_from_integral_for_locale
|
||||
// test_conversion_from_to_integral_for_locale
|
||||
|
||||
typedef std::numpunct<char> numpunct;
|
||||
|
||||
@@ -527,7 +613,7 @@ void test_conversion_from_integral()
|
||||
std::string grouping1 = BOOST_USE_FACET(numpunct, oldloc).grouping();
|
||||
std::string grouping2(grouping1);
|
||||
|
||||
test_conversion_from_integral_for_locale<T>();
|
||||
test_conversion_from_to_integral_for_locale<T>();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -544,64 +630,121 @@ void test_conversion_from_integral()
|
||||
}
|
||||
|
||||
if(grouping1 != grouping2)
|
||||
test_conversion_from_integral_for_locale<T>();
|
||||
test_conversion_from_to_integral_for_locale<T>();
|
||||
|
||||
if(grouping1.empty() && grouping2.empty())
|
||||
BOOST_TEST_MESSAGE("Formatting with thousands_sep has not been tested");
|
||||
}
|
||||
|
||||
void test_conversion_from_short()
|
||||
void test_conversion_from_to_short()
|
||||
{
|
||||
test_conversion_from_integral<short>();
|
||||
test_conversion_from_to_integral<short>();
|
||||
}
|
||||
|
||||
void test_conversion_from_ushort()
|
||||
void test_conversion_from_to_ushort()
|
||||
{
|
||||
test_conversion_from_integral<unsigned short>();
|
||||
test_conversion_from_to_integral<unsigned short>();
|
||||
}
|
||||
|
||||
void test_conversion_from_int()
|
||||
void test_conversion_from_to_int()
|
||||
{
|
||||
test_conversion_from_integral<int>();
|
||||
test_conversion_from_to_integral<int>();
|
||||
}
|
||||
|
||||
void test_conversion_from_uint()
|
||||
void test_conversion_from_to_uint()
|
||||
{
|
||||
test_conversion_from_integral<unsigned int>();
|
||||
test_conversion_from_to_integral<unsigned int>();
|
||||
}
|
||||
|
||||
void test_conversion_from_ulong()
|
||||
void test_conversion_from_to_ulong()
|
||||
{
|
||||
test_conversion_from_integral<unsigned long>();
|
||||
test_conversion_from_to_integral<unsigned long>();
|
||||
}
|
||||
|
||||
void test_conversion_from_long()
|
||||
void test_conversion_from_to_long()
|
||||
{
|
||||
test_conversion_from_integral<long>();
|
||||
test_conversion_from_to_integral<long>();
|
||||
}
|
||||
|
||||
#if defined(BOOST_HAS_LONG_LONG)
|
||||
|
||||
void test_conversion_from_longlong()
|
||||
void test_conversion_from_to_longlong()
|
||||
{
|
||||
test_conversion_from_integral<boost::long_long_type>();
|
||||
test_conversion_from_to_integral<boost::long_long_type>();
|
||||
}
|
||||
|
||||
void test_conversion_from_ulonglong()
|
||||
void test_conversion_from_to_ulonglong()
|
||||
{
|
||||
test_conversion_from_integral<boost::ulong_long_type>();
|
||||
test_conversion_from_to_integral<boost::ulong_long_type>();
|
||||
}
|
||||
|
||||
#elif defined(LCAST_TEST_LONGLONG)
|
||||
|
||||
void test_conversion_from_longlong()
|
||||
void test_conversion_from_to_longlong()
|
||||
{
|
||||
test_conversion_from_integral<__int64>();
|
||||
test_conversion_from_to_integral<__int64>();
|
||||
}
|
||||
|
||||
void test_conversion_from_ulonglong()
|
||||
void test_conversion_from_to_ulonglong()
|
||||
{
|
||||
test_conversion_from_integral<unsigned __int64>();
|
||||
test_conversion_from_to_integral<unsigned __int64>();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
void test_traits()
|
||||
{
|
||||
typedef std::basic_string<char, my_traits<char> > my_string;
|
||||
|
||||
my_string const s("s");
|
||||
BOOST_CHECK(boost::lexical_cast<char>(s) == s[0]);
|
||||
BOOST_CHECK(boost::lexical_cast<my_string>(s) == s);
|
||||
BOOST_CHECK(boost::lexical_cast<my_string>(-1) == "-1");
|
||||
}
|
||||
|
||||
void test_wtraits()
|
||||
{
|
||||
typedef std::basic_string<wchar_t, my_traits<wchar_t> > my_string;
|
||||
|
||||
my_string const s(L"s");
|
||||
BOOST_CHECK(boost::lexical_cast<wchar_t>(s) == s[0]);
|
||||
BOOST_CHECK(boost::lexical_cast<my_string>(s) == s);
|
||||
//BOOST_CHECK(boost::lexical_cast<my_string>(-1) == L"-1");
|
||||
// Commented out because gcc 3.3 doesn't support this:
|
||||
// basic_ostream<wchar_t, my_traits<wchar_t> > o; o << -1;
|
||||
}
|
||||
|
||||
void test_allocator()
|
||||
{
|
||||
typedef std::basic_string< char
|
||||
, std::char_traits<char>
|
||||
, my_allocator<char>
|
||||
> my_string;
|
||||
|
||||
my_string s("s");
|
||||
BOOST_CHECK(boost::lexical_cast<char>(s) == s[0]);
|
||||
BOOST_CHECK(boost::lexical_cast<std::string>(s) == "s");
|
||||
BOOST_CHECK(boost::lexical_cast<my_string>(s) == s);
|
||||
BOOST_CHECK(boost::lexical_cast<my_string>(1) == "1");
|
||||
BOOST_CHECK(boost::lexical_cast<my_string>("s") == s);
|
||||
BOOST_CHECK(boost::lexical_cast<my_string>(std::string("s")) == s);
|
||||
}
|
||||
|
||||
void test_wallocator()
|
||||
{
|
||||
typedef std::basic_string< wchar_t
|
||||
, std::char_traits<wchar_t>
|
||||
, my_allocator<wchar_t>
|
||||
> my_string;
|
||||
|
||||
my_string s(L"s");
|
||||
BOOST_CHECK(boost::lexical_cast<wchar_t>(s) == s[0]);
|
||||
BOOST_CHECK(boost::lexical_cast<std::wstring>(s) == L"s");
|
||||
BOOST_CHECK(boost::lexical_cast<my_string>(s) == s);
|
||||
BOOST_CHECK(boost::lexical_cast<my_string>(1) == L"1");
|
||||
BOOST_CHECK(boost::lexical_cast<my_string>(L"s") == s);
|
||||
BOOST_CHECK(boost::lexical_cast<my_string>(std::wstring(L"s")) == s);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user