Compare commits

..

13 Commits

Author SHA1 Message Date
Beman Dawes 3271717a5d Release 1.50.0
[SVN r79156]
2012-06-28 12:37:29 +00:00
Antony Polukhin 79d6468aeb Merge lexical_cast from trunk :
* force SunCC compiler to use fallback version of lexical_cast (with fallbak version SunCC can pass at least some tests)
* removed trailing whitespaces

[SVN r78565]
2012-05-24 04:22:04 +00:00
Antony Polukhin ca9c8d30bd Merge from trunk:
* Fixes ISO C++ does not support the ‘%lg’ gnu_printf format (refs #6852)
* explicit-failures-markup merge from trunk
* supress warnings in implicit_cast.cpp test

[SVN r78450]
2012-05-13 08:15:51 +00:00
Antony Polukhin b1b5305984 Merge from trunk:
* fixed #6812 (now converting "." to float type throws bad_lexical_cast)

[SVN r78211]
2012-04-26 17:59:17 +00:00
Antony Polukhin eb4ad73caf Merge lexical_cast library from trunk:
* multiple optimizations and bugfixes for boost::iterator_range (refs #6786, refs #6430, refs #6663)
* documentation update
* new Unicode characters support updated
* much more tests, removed incorrect tests

[SVN r78059]
2012-04-18 04:09:49 +00:00
Antony Polukhin 1e58331baf Merge lexical_cast from trunk:
* fixed #6717 (now lexical_cast won`t try to support non confirming swprintf)
* fixed #6670 (now using BOOST_NO_UNICODE_LITERALS macro to detect unicode literals support)
* rewritten Jamfile

[SVN r77804]
2012-04-07 07:52:23 +00:00
Antony Polukhin 93ee01ab69 Merge from trunk r77627 (merged lexical_cast optimizations for iterator_range<>, fixed performance regression, docs updated)
[SVN r77628]
2012-03-29 16:48:31 +00:00
Antony Polukhin a065884c59 Merge from trunk
* Much more tests
* Now numeric_cast (and lexical_cast) can be compiled with disabled exceptions
* Supress warning described in #6645 (implicit conversion shortens 64-bit value into a 32-bit value)
* Fixed compilation of lexical_cast with BOOST_NO_STD_LOCALE defined
* Documentation updates
* Case insensitive "NaN" and "Inf" parsing 
* Performance tests commit

[SVN r77288]
2012-03-10 07:31:36 +00:00
Antony Polukhin e51cf081b3 Merge from trunk (fixed #6251, fixed #6453, disabled some optimizations for sunCC #6462)
[SVN r76887]
2012-02-04 18:04:45 +00:00
Antony Polukhin 51a6aacb57 Merge from trunk r76357
(tiny documentation update)

[SVN r76358]
2012-01-08 09:25:04 +00:00
Antony Polukhin a2e4606e6c Merge from trunk r76354
(Fixes overflow detection, pointers casts)

[SVN r76355]
2012-01-08 09:05:35 +00:00
Antony Polukhin 82abf7b54f Merge from trunk r76232
[SVN r76233]
2011-12-30 15:18:00 +00:00
Antony Polukhin 7112ded1b9 Merge from trunk r75937
* fixed a lot of wchar_t errors
* Optimizations for boost::containers::basic_string
* More tests

[SVN r76062]
2011-12-19 15:19:43 +00:00
23 changed files with 2564 additions and 867 deletions
+3 -3
View File
@@ -6,9 +6,9 @@ using quickbook ;
import boostbook : boostbook ;
xml lexical_cast : lexical_cast.qbk ;
boostbook standalone
:
lexical_cast
boostbook standalone
:
lexical_cast
:
<xsl:param>boost.root=../../../..
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html
+515 -370
View File
@@ -3,7 +3,7 @@
[version 1.0]
[copyright 2000-2005 Kevlin Henney]
[copyright 2006-2010 Alexander Nasonov]
[copyright 2011 Antony Polukhin]
[copyright 2011-2012 Antony Polukhin]
[category String and text processing]
[category Miscellaneous]
[license
@@ -34,7 +34,7 @@ The standard C++ library offers `stringstream` for the kind of in-core formattin
The `lexical_cast` function template offers a convenient and consistent form for supporting common conversions to and from arbitrary types when they are represented as text. The simplification it offers is in expression-level convenience for such conversions. For more involved conversions, such as where precision or formatting need tighter control than is offered by the default behavior of `lexical_cast`, the conventional `std::stringstream` approach is recommended. Where the conversions are numeric to numeric, __numericcast__ may offer more reasonable behavior than `lexical_cast`.
For a good discussion of the options and issues involved in string-based formatting, including comparison of `stringstream`, `lexical_cast`, and others, see Herb Sutter's article, [@http://www.gotw.ca/publications/mill19.htm The String Formatters of Manor Farm]. Also, take a look at the [link boost_lexical_cast.performance Performance] section.
For a good discussion of the options and issues involved in string-based formatting, including comparison of `stringstream`, `lexical_cast`, and others, see Herb Sutter's article, [@http://www.gotw.ca/publications/mill19.htm The String Formatters of Manor Farm]. Also, take a look at the [link boost_lexical_cast.performance Performance] section.
[endsect]
[section Examples]
@@ -97,7 +97,21 @@ The requirements on the argument and result types are:
* Target is CopyConstructible [20.1.3].
* Target is DefaultConstructible, meaning that it is possible to default-initialize an object of that type [8.5, 20.1.4].
The character type of the underlying stream is assumed to be char unless either the Source or the Target requires wide-character streaming, in which case the underlying stream uses `wchar_t`. Source types that require wide-character streaming are `wchar_t`, `wchar_t *`, and `std::wstring`. Target types that require wide-character streaming are `wchar_t` and `std::wstring`.
The character type of the underlying stream is assumed to be `char` unless either the `Source` or the `Target` requires wide-character streaming, in which case the underlying stream uses `wchar_t`, `char16_t` or `char32_t`. Wide-character streaming is currently detected for:
* Single character: `wchar_t`, `char16_t`, `char32_t`
* Arrays of characters: `wchar_t *`, `char16_t *`, `char32_t *`, `const wchar_t *`, `const char16_t *`, `const char32_t *`
* Strings: `std::basic_string`, `boost::containers::basic_string`
* `boost::iterator_range<WideCharPtr>`, where `WideCharPtr` is a pointer to wide-character or pointer to const wide-character
[important Many compilers and runtime libraries fail to make conversions using new Unicode characters. Make shure that the following code compiles and outputs nonzero values, before using new types:
``
std::cout
<< booat::lexical_cast<std::u32string>(1.0).size()
<< " "
<< booat::lexical_cast<std::u16string>(1.0).size();
``
]
Where a higher degree of control is required over conversions, `std::stringstream` and `std::wstringstream` offer a more appropriate path. Where non-stream-based conversions are required, `lexical_cast` is the wrong tool for the job and is not special-cased for such scenarios.
[endsect]
@@ -115,38 +129,88 @@ Exception used to indicate runtime lexical_cast failure.
[endsect]
[/ Commenting out bad advise (this will break the ability to get correct function pointers via &lexical_cast<Target, Source>)
[section Tuning classes for fast lexical conversions]
Because of `boost::lexical_cast` optimizations for `boost::iterator_range<character_type*>`, it is possibile to make very fast lexical conversions for non zero terminated strings, substrings and user-defined classes.
Consider the following example:
``
class example_class {
char non_zero_terminated_data[10];
std::size_t data_length;
public:
example_class();
void fill_data();
const char* data() const {
return non_zero_terminated_data;
}
std::size_t size() const {
return data_length;
}
};
inline std::ostream& operator << (std::ostream& ostr, const example_class& rhs) {
return ostr << boost::make_iterator_range(rhs.data(), rhs.data() + rhs.size());
}
``
This is a good generic solution for most use cases.
But we can make it even faster for some performance critical applications. During conversion, we loose speed at:
* `std::ostream` construction (it makes some heap allocations)
* `operator <<` (it copyies one by one all the symbols to an instance of `std::ostream`)
* `std::ostream` destruction (it makes some heap deallocations)
We can avoid all of this, by specifieng an overload for `boost::lexical_cast`:
``
namespace boost {
template <class OutT>
OutT lexical_cast(const example_class& rhs) {
return boost::lexical_cast<OutT>(
boost::make_iterator_range(rhs.data(), rhs.data() + rhs.size())
);
}
}
``
Now `boost::lexical_cast<some_type>(example_class_instance)` conversions won't copy data and construct heavy STL stream objects. See [link boost_lexical_cast.performance Performance] section for info on `boost::iterator_range` conversion performance.
[endsect]
]
[section Frequently Asked Questions]
* [*Question:] Why does `lexical_cast<int8_t>("127")` throw `bad_lexical_cast`?
* [*Answer:] The type `int8_t` is a `typedef` to `char` or `signed char`. Lexical conversion to these types is simply reading a byte from source but since the source has more than one byte, the exception is thrown.
Please use other integer types such as `int` or `short int`. If bounds checking is important, you can also
call __numericcast__:
* [*Answer:] The type `int8_t` is a `typedef` to `char` or `signed char`. Lexical conversion to these types is simply reading a byte from source but since the source has more than one byte, the exception is thrown.
Please use other integer types such as `int` or `short int`. If bounds checking is important, you can also
call __numericcast__:
`numeric_cast<int8_t>(lexical_cast<int>("127"));`
[pre
]
* [*Question:] Why does `lexical_cast<unsigned char>("127")` throw `bad_lexical_cast`?
* [*Answer:] Lexical conversion to any char type is simply reading a byte from source. But since the source has more than one byte, the exception is thrown.
Please use other integer types such as `int` or `short int`. If bounds checking is important, you can also
call __numericcast__:
* [*Answer:] Lexical conversion to any char type is simply reading a byte from source. But since the source has more than one byte, the exception is thrown.
Please use other integer types such as `int` or `short int`. If bounds checking is important, you can also
call __numericcast__:
`numeric_cast<unsigned char>(lexical_cast<int>("127"));`
[pre
]
* [*Question:] What does `lexical_cast<std::string>` of an `int8_t` or `uint8_t` not do what I expect?
* [*Answer:] As above, note that int8_t and uint8_t are actually chars and are formatted as such. To avoid
* [*Answer:] As above, note that int8_t and uint8_t are actually chars and are formatted as such. To avoid
this, cast to an integer type first: `lexical_cast<std::string>(static_cast<int>(n));`
[pre
]
* [*Question:] The implementation always resets the `ios_base::skipws` flag of an underlying stream object.
* [*Question:] The implementation always resets the `ios_base::skipws` flag of an underlying stream object.
It breaks my `operator>>` that works only in presence of this flag. Can you remove code that resets the flag?
* [*Answer:] May be in a future version. There is no requirement in
__proposallong__ to reset the flag but
remember that __proposalshort__ is not yet accepted by the committee. By the way, it's a great opportunity to
* [*Answer:] May be in a future version. There is no requirement in
__proposallong__ to reset the flag but
remember that __proposalshort__ is not yet accepted by the committee. By the way, it's a great opportunity to
make your `operator>>` conform to the standard.
Read a good C++ book, study `std::sentry` and [@boost:libs/io/doc/ios_state.html `ios_state_saver`].
@@ -154,19 +218,49 @@ Read a good C++ book, study `std::sentry` and [@boost:libs/io/doc/ios_state.html
]
* [*Question:] Why `std::cout << boost::lexical_cast<unsigned int>("-1");` does not throw, but outputs 4294967295?
* [*Answer:] `boost::lexical_cast` has the behavior of `std::stringstream`, which uses `num_get` functions of
`std::locale` to convert numbers. If we look at the Programming languages — C++, we'll see, that `num_get` uses
the rules of `scanf` for conversions. And in the C99 standard for unsigned input value minus sign is optional, so
* [*Answer:] `boost::lexical_cast` has the behavior of `std::stringstream`, which uses `num_get` functions of
`std::locale` to convert numbers. If we look at the Programming languages — C++, we'll see, that `num_get` uses
the rules of `scanf` for conversions. And in the C99 standard for unsigned input value minus sign is optional, so
if a negative number is read, no errors will arise and the result will be the two's complement.
[pre
]
* [*Question:] Why `boost::lexical_cast<int>(L'A');` outputs 65 and `boost::lexical_cast<wchar_t>(L"65");` does not throw?
* [*Answer:] If you are using an old version of Visual Studio or compile code with /Zc:wchar_t- flag,
`boost::lexical_cast` sees single `wchar_t` character as `unsigned short`. It is not a `boost::lexical_cast` mistake, but a
limitation of compiler options that you use.
[pre
]
* [*Question:] Why `boost::lexical_cast<double>("-1.#IND");` throws `boost::bad_lexical_cast`?
* [*Answer:] `"-1.#IND"` is a compiler extension, that violates standard. You shall input `"-nan"`, `"nan"`, `"inf"`
, `"-inf"` (case insensitive) strings to get NaN and Inf values. `boost::lexical_cast<string>` outputs `"-nan"`, `"nan"`,
`"inf"`, `"-inf"` strings, when has NaN or Inf input values.
* [*Question:] What is the fastest way to convert a non zero terminated string or a substring using `boost::lexical_cast`?
* [*Answer:] Use `boost::iterator_range` for conversion. For example, if you whant to convert to `int` two characters from a string `str`, you shall write `lexacal_cast<int>(make_iterator_range(str.c_str(), str.c_str() + 2));`.
[endsect]
[section Changes]
* [*boost 1.50.0 :]
* `boost::bad_lexical_cast` exception is now globaly visible and can be catched even if code is compiled with -fvisibility=hidden.
* Now it is possible to compile library with disabled exceptions.
* Better performance, less memory usage and bugfixes for `boost::iterator_range<character_type*>` conversions.
* [*boost 1.49.0 :]
* Restored work with typedefed wchar_t (compilation flag /Zc:wchar_t- for Visual Studio).
* Better performance and less memory usage for `boost::container::basic_string` conversions.
* [*boost 1.48.0 :]
* Added code to work with Inf and NaN on any platform.
* Added code to work with Inf and NaN on any platform.
* Better performance and less memory usage for conversions to float type (and to double type, if `sizeof(double) < sizeof(long double)`).
* [*boost 1.47.0 :]
* Optimizations for "C" and other locales without number grouping.
@@ -189,7 +283,7 @@ if a negative number is read, no errors will arise and the result will be the tw
* The previous version of lexical_cast used the default stream precision for reading and writing floating-point numbers. For numerics that have a corresponding specialization of `std::numeric_limits`, the current version now chooses a precision to match.
* The previous version of lexical_cast did not support conversion to or from any wide-character-based types. For compilers with full language and library support for wide characters, `lexical_cast` now supports conversions from `wchar_t`, `wchar_t *`, and `std::wstring` and to `wchar_t` and `std::wstring`.
* The previous version of `lexical_cast` assumed that the conventional stream extractor operators were sufficient for reading values. However, string I/O is asymmetric, with the result that spaces play the role of I/O separators rather than string content. The current version fixes this error for `std::string` and, where supported, `std::wstring`: `lexical_cast<std::string>("Hello, World")` succeeds instead of failing with a `bad_lexical_cast` exception.
* The previous version of `lexical_cast` allowed unsafe and meaningless conversions to pointers. The current version now throws a `bad_lexical_cast` for conversions to pointers: `lexical_cast<char *>("Goodbye, World")` now throws an exception instead of causing undefined behavior.
* The previous version of `lexical_cast` allowed unsafe and meaningless conversions to pointers. The current version now throws a `bad_lexical_cast` for conversions to pointers: `lexical_cast<char *>("Goodbye, World")` now throws an exception instead of causing undefined behavior.
[endsect]
@@ -234,371 +328,422 @@ All the tests measure execution speed in milliseconds for 10000 iterations of th
``]
]
]
Fastest results are highlitened with "!!! *x* !!!".
Fastest results are highlitened with "!!! *x* !!!".
Do not use this results to compare compilers, because tests were taken on different hardware.
[endsect]
[/ BEGIN of section, generated by performance measuring program ]
[section clang-linux-2.8][table:id Performance Table (clang-linux-2.8)
[section Clang version 2.9 (tags/RELEASE_29/final)]
[table:id Performance Table ( Clang version 2.9 (tags/RELEASE_29/final))
[[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]]
[[ string->char ][ !!! *<1* !!! ][ 148 ][ 14 ][ 12 ]]
[[ string->signed char ][ !!! *<1* !!! ][ 97 ][ 8 ][ 7 ]]
[[ string->unsigned char ][ !!! *<1* !!! ][ 90 ][ 8 ][ 13 ]]
[[ string->int ][ !!! *4* !!! ][ 102 ][ 19 ][ 15 ]]
[[ string->short ][ !!! *4* !!! ][ 105 ][ 20 ][ 15 ]]
[[ string->long int ][ !!! *4* !!! ][ 105 ][ 19 ][ 15 ]]
[[ string->long long ][ !!! *4* !!! ][ 115 ][ 19 ][ 14 ]]
[[ string->unsigned int ][ !!! *4* !!! ][ 102 ][ 18 ][ 14 ]]
[[ string->unsigned short ][ !!! *4* !!! ][ 101 ][ 19 ][ 15 ]]
[[ string->unsigned long int ][ !!! *3* !!! ][ 107 ][ 20 ][ 14 ]]
[[ string->unsigned long long ][ !!! *3* !!! ][ 103 ][ 20 ][ 14 ]]
[[ string->bool ][ !!! *<1* !!! ][ 97 ][ 16 ][ 8 ]]
[[ string->float ][ !!! *21* !!! ][ 170 ][ 61 ][ 32 ]]
[[ string->double ][ !!! *18* !!! ][ 206 ][ 93 ][ 58 ]]
[[ string->long double ][ 135 ][ 221 ][ 94 ][ !!! *57* !!! ]]
[[ char->string ][ !!! *7* !!! ][ 100 ][ 17 ][ 13 ]]
[[ unsigned char->string ][ !!! *7* !!! ][ 99 ][ 18 ][ 16 ]]
[[ signed char->string ][ !!! *7* !!! ][ 101 ][ 17 ][ 12 ]]
[[ int->string ][ !!! *13* !!! ][ 110 ][ 23 ][ 15 ]]
[[ short->string ][ !!! *13* !!! ][ 112 ][ 24 ][ 18 ]]
[[ long int->string ][ !!! *13* !!! ][ 119 ][ 23 ][ 17 ]]
[[ long long->string ][ !!! *13* !!! ][ 110 ][ 23 ][ 18 ]]
[[ unsigned int->string ][ !!! *14* !!! ][ 113 ][ 24 ][ 17 ]]
[[ unsigned short->string ][ !!! *13* !!! ][ 108 ][ 24 ][ 17 ]]
[[ unsigned long int->string ][ !!! *13* !!! ][ 109 ][ 24 ][ 16 ]]
[[ unsigned long long->string ][ !!! *13* !!! ][ 110 ][ 23 ][ 17 ]]
[[ bool->string ][ !!! *7* !!! ][ 105 ][ 24 ][ 12 ]]
[[ float->string ][ 70 ][ 192 ][ 94 ][ !!! *49* !!! ]]
[[ double->string ][ 106 ][ 217 ][ 122 ][ !!! *76* !!! ]]
[[ long double->string ][ 120 ][ 219 ][ 123 ][ !!! *80* !!! ]]
[[ char*->char ][ !!! *2* !!! ][ 90 ][ 9 ][ 8 ]]
[[ char*->signed char ][ !!! *2* !!! ][ 87 ][ 10 ][ 7 ]]
[[ char*->unsigned char ][ !!! *3* !!! ][ 90 ][ 10 ][ 13 ]]
[[ char*->int ][ !!! *6* !!! ][ 107 ][ 21 ][ 15 ]]
[[ char*->short ][ !!! *6* !!! ][ 110 ][ 19 ][ 14 ]]
[[ char*->long int ][ !!! *6* !!! ][ 103 ][ 19 ][ 14 ]]
[[ char*->long long ][ !!! *7* !!! ][ 104 ][ 20 ][ 15 ]]
[[ char*->unsigned int ][ !!! *6* !!! ][ 101 ][ 20 ][ 15 ]]
[[ char*->unsigned short ][ !!! *7* !!! ][ 100 ][ 20 ][ 14 ]]
[[ char*->unsigned long int ][ !!! *6* !!! ][ 105 ][ 22 ][ 15 ]]
[[ char*->unsigned long long ][ !!! *7* !!! ][ 106 ][ 21 ][ 14 ]]
[[ char*->bool ][ !!! *2* !!! ][ 99 ][ 18 ][ 7 ]]
[[ char*->float ][ !!! *22* !!! ][ 159 ][ 67 ][ 33 ]]
[[ char*->double ][ !!! *20* !!! ][ 205 ][ 94 ][ 58 ]]
[[ char*->long double ][ 140 ][ 214 ][ 95 ][ !!! *58* !!! ]]
[[ unsigned char*->char ][ !!! *2* !!! ][ 92 ][ 9 ][ 7 ]]
[[ unsigned char*->signed char ][ !!! *2* !!! ][ 89 ][ 10 ][ 7 ]]
[[ unsigned char*->unsigned char ][ !!! *2* !!! ][ 89 ][ 10 ][ 14 ]]
[[ unsigned char*->int ][ !!! *6* !!! ][ 104 ][ 20 ][ 14 ]]
[[ unsigned char*->short ][ !!! *6* !!! ][ 106 ][ 21 ][ 14 ]]
[[ unsigned char*->long int ][ !!! *6* !!! ][ 105 ][ 19 ][ 14 ]]
[[ unsigned char*->long long ][ !!! *6* !!! ][ 106 ][ 20 ][ 15 ]]
[[ unsigned char*->unsigned int ][ !!! *7* !!! ][ 105 ][ 19 ][ 14 ]]
[[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 103 ][ 19 ][ 14 ]]
[[ unsigned char*->unsigned long int ][ !!! *6* !!! ][ 106 ][ 19 ][ 14 ]]
[[ unsigned char*->unsigned long long ][ !!! *6* !!! ][ 104 ][ 21 ][ 15 ]]
[[ unsigned char*->bool ][ !!! *2* !!! ][ 102 ][ 18 ][ 7 ]]
[[ unsigned char*->float ][ !!! *23* !!! ][ 160 ][ 66 ][ 32 ]]
[[ unsigned char*->double ][ !!! *20* !!! ][ 201 ][ 95 ][ 58 ]]
[[ unsigned char*->long double ][ 144 ][ 221 ][ 95 ][ !!! *60* !!! ]]
[[ unsigned char*->string ][ !!! *12* !!! ][ 104 ][ 23 ][ --- ]]
[[ signed char*->char ][ !!! *2* !!! ][ 90 ][ 9 ][ 7 ]]
[[ signed char*->signed char ][ !!! *2* !!! ][ 89 ][ 9 ][ 7 ]]
[[ signed char*->unsigned char ][ !!! *2* !!! ][ 89 ][ 10 ][ 13 ]]
[[ signed char*->int ][ !!! *6* !!! ][ 106 ][ 19 ][ 15 ]]
[[ signed char*->short ][ !!! *6* !!! ][ 107 ][ 20 ][ 15 ]]
[[ signed char*->long int ][ !!! *6* !!! ][ 103 ][ 19 ][ 14 ]]
[[ signed char*->long long ][ !!! *6* !!! ][ 103 ][ 19 ][ 14 ]]
[[ signed char*->unsigned int ][ !!! *6* !!! ][ 101 ][ 19 ][ 15 ]]
[[ signed char*->unsigned short ][ !!! *6* !!! ][ 101 ][ 19 ][ 16 ]]
[[ signed char*->unsigned long int ][ !!! *6* !!! ][ 105 ][ 22 ][ 15 ]]
[[ signed char*->unsigned long long ][ !!! *6* !!! ][ 104 ][ 21 ][ 15 ]]
[[ signed char*->bool ][ !!! *2* !!! ][ 100 ][ 18 ][ 7 ]]
[[ signed char*->float ][ !!! *23* !!! ][ 161 ][ 62 ][ 32 ]]
[[ signed char*->double ][ !!! *20* !!! ][ 207 ][ 102 ][ 57 ]]
[[ signed char*->long double ][ 144 ][ 216 ][ 96 ][ !!! *63* !!! ]]
[[ signed char*->string ][ !!! *12* !!! ][ 104 ][ 23 ][ --- ]]
[[ int->int ][ !!! *<1* !!! ][ 110 ][ 22 ][ --- ]]
[[ float->double ][ !!! *<1* !!! ][ 223 ][ 113 ][ --- ]]
[[ double->double ][ !!! *<1* !!! ][ 227 ][ 111 ][ --- ]]
[[ int->int ][ !!! *<1* !!! ][ 231 ][ 122 ][ --- ]]
[[ int->int ][ !!! *<1* !!! ][ 229 ][ 121 ][ --- ]]
[[ char->unsigned char ][ !!! *<1* !!! ][ 90 ][ 8 ][ --- ]]
[[ char->signed char ][ !!! *<1* !!! ][ 88 ][ 8 ][ --- ]]
[[ unsigned char->char ][ !!! *<1* !!! ][ 89 ][ 8 ][ --- ]]
[[ signed char->char ][ !!! *<1* !!! ][ 91 ][ 9 ][ --- ]]
[[ string->char ][ !!! *<1* !!! ][ 319 ][ 17 ][ 16 ]]
[[ string->signed char ][ !!! *<1* !!! ][ 192 ][ 16 ][ 9 ]]
[[ string->unsigned char ][ !!! *<1* !!! ][ 142 ][ 9 ][ 9 ]]
[[ string->int ][ !!! *7* !!! ][ 109 ][ 21 ][ 16 ]]
[[ string->short ][ !!! *6* !!! ][ 113 ][ 21 ][ 15 ]]
[[ string->long int ][ !!! *7* !!! ][ 110 ][ 22 ][ 15 ]]
[[ string->long long ][ !!! *7* !!! ][ 112 ][ 23 ][ 17 ]]
[[ string->unsigned int ][ !!! *6* !!! ][ 107 ][ 19 ][ 14 ]]
[[ string->unsigned short ][ !!! *6* !!! ][ 106 ][ 18 ][ 16 ]]
[[ string->unsigned long int ][ !!! *7* !!! ][ 108 ][ 20 ][ 15 ]]
[[ string->unsigned long long ][ !!! *7* !!! ][ 109 ][ 22 ][ 15 ]]
[[ string->float ][ !!! *14* !!! ][ 204 ][ 81 ][ 43 ]]
[[ string->double ][ !!! *24* !!! ][ 244 ][ 74 ][ 45 ]]
[[ string->long double ][ 121 ][ 170 ][ 62 ][ !!! *38* !!! ]]
[[ string->string ][ !!! *1* !!! ][ 124 ][ 25 ][ --- ]]
[[ string->container::string ][ !!! *3* !!! ][ 121 ][ 28 ][ --- ]]
[[ string->char ][ 6 ][ 115 ][ 26 ][ !!! *6* !!! ]]
[[ string->signed char ][ !!! *6* !!! ][ 115 ][ 23 ][ 21 ]]
[[ string->unsigned char ][ !!! *6* !!! ][ 113 ][ 25 ][ 22 ]]
[[ int->string ][ !!! *12* !!! ][ 128 ][ 29 ][ 19 ]]
[[ short->string ][ !!! *12* !!! ][ 128 ][ 29 ][ 21 ]]
[[ long int->string ][ !!! *12* !!! ][ 132 ][ 29 ][ 21 ]]
[[ long long->string ][ !!! *12* !!! ][ 127 ][ 29 ][ 22 ]]
[[ unsigned int->string ][ !!! *12* !!! ][ 137 ][ 33 ][ 19 ]]
[[ unsigned short->string ][ !!! *12* !!! ][ 137 ][ 31 ][ 20 ]]
[[ unsigned long int->string ][ !!! *12* !!! ][ 136 ][ 30 ][ 21 ]]
[[ unsigned long long->string ][ !!! *12* !!! ][ 128 ][ 27 ][ 23 ]]
[[ float->string ][ 51 ][ 187 ][ 82 ][ !!! *44* !!! ]]
[[ double->string ][ 56 ][ 190 ][ 83 ][ !!! *42* !!! ]]
[[ long double->string ][ 69 ][ 208 ][ 90 ][ !!! *54* !!! ]]
[[ char*->char ][ !!! *<1* !!! ][ 138 ][ 18 ][ 8 ]]
[[ char*->signed char ][ !!! *8* !!! ][ 126 ][ 10 ][ 9 ]]
[[ char*->unsigned char ][ !!! *<1* !!! ][ 98 ][ 9 ][ 9 ]]
[[ char*->int ][ !!! *8* !!! ][ 113 ][ 22 ][ 15 ]]
[[ char*->short ][ !!! *7* !!! ][ 113 ][ 22 ][ 17 ]]
[[ char*->long int ][ !!! *8* !!! ][ 111 ][ 23 ][ 15 ]]
[[ char*->long long ][ !!! *9* !!! ][ 112 ][ 24 ][ 18 ]]
[[ char*->unsigned int ][ !!! *8* !!! ][ 113 ][ 20 ][ 15 ]]
[[ char*->unsigned short ][ !!! *8* !!! ][ 113 ][ 20 ][ 15 ]]
[[ char*->unsigned long int ][ !!! *8* !!! ][ 112 ][ 21 ][ 16 ]]
[[ char*->unsigned long long ][ !!! *9* !!! ][ 110 ][ 23 ][ 14 ]]
[[ char*->float ][ !!! *14* !!! ][ 149 ][ 54 ][ 32 ]]
[[ char*->double ][ !!! *15* !!! ][ 166 ][ 59 ][ 33 ]]
[[ char*->long double ][ 122 ][ 171 ][ 63 ][ !!! *38* !!! ]]
[[ char*->string ][ !!! *7* !!! ][ 126 ][ 26 ][ --- ]]
[[ char*->container::string ][ !!! *2* !!! ][ 124 ][ 27 ][ --- ]]
[[ unsigned char*->char ][ !!! *<1* !!! ][ 99 ][ 10 ][ 8 ]]
[[ unsigned char*->signed char ][ !!! *<1* !!! ][ 102 ][ 10 ][ 9 ]]
[[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 98 ][ 10 ][ 9 ]]
[[ unsigned char*->int ][ !!! *7* !!! ][ 115 ][ 24 ][ 15 ]]
[[ unsigned char*->short ][ !!! *7* !!! ][ 115 ][ 25 ][ 17 ]]
[[ unsigned char*->long int ][ !!! *8* !!! ][ 115 ][ 22 ][ 16 ]]
[[ unsigned char*->long long ][ !!! *8* !!! ][ 116 ][ 23 ][ 16 ]]
[[ unsigned char*->unsigned int ][ !!! *8* !!! ][ 113 ][ 20 ][ 14 ]]
[[ unsigned char*->unsigned short ][ !!! *7* !!! ][ 114 ][ 21 ][ 15 ]]
[[ unsigned char*->unsigned long int ][ !!! *8* !!! ][ 114 ][ 21 ][ 14 ]]
[[ unsigned char*->unsigned long long ][ !!! *9* !!! ][ 112 ][ 23 ][ 16 ]]
[[ unsigned char*->float ][ !!! *14* !!! ][ 149 ][ 52 ][ 32 ]]
[[ unsigned char*->double ][ !!! *15* !!! ][ 165 ][ 59 ][ 33 ]]
[[ unsigned char*->long double ][ 122 ][ 172 ][ 63 ][ !!! *37* !!! ]]
[[ unsigned char*->string ][ !!! *8* !!! ][ 125 ][ 26 ][ --- ]]
[[ unsigned char*->container::string ][ !!! *4* !!! ][ 119 ][ 26 ][ --- ]]
[[ signed char*->char ][ !!! *<1* !!! ][ 98 ][ 10 ][ 8 ]]
[[ signed char*->signed char ][ !!! *<1* !!! ][ 95 ][ 10 ][ 9 ]]
[[ signed char*->unsigned char ][ !!! *<1* !!! ][ 98 ][ 9 ][ 9 ]]
[[ signed char*->int ][ !!! *8* !!! ][ 111 ][ 21 ][ 15 ]]
[[ signed char*->short ][ !!! *7* !!! ][ 114 ][ 22 ][ 16 ]]
[[ signed char*->long int ][ !!! *8* !!! ][ 113 ][ 22 ][ 17 ]]
[[ signed char*->long long ][ !!! *8* !!! ][ 116 ][ 24 ][ 17 ]]
[[ signed char*->unsigned int ][ !!! *8* !!! ][ 109 ][ 20 ][ 15 ]]
[[ signed char*->unsigned short ][ !!! *8* !!! ][ 111 ][ 20 ][ 14 ]]
[[ signed char*->unsigned long int ][ !!! *8* !!! ][ 109 ][ 22 ][ 15 ]]
[[ signed char*->unsigned long long ][ !!! *8* !!! ][ 111 ][ 23 ][ 15 ]]
[[ signed char*->float ][ !!! *14* !!! ][ 150 ][ 53 ][ 32 ]]
[[ signed char*->double ][ !!! *15* !!! ][ 168 ][ 59 ][ 30 ]]
[[ signed char*->long double ][ 123 ][ 174 ][ 62 ][ !!! *37* !!! ]]
[[ signed char*->string ][ !!! *8* !!! ][ 127 ][ 28 ][ --- ]]
[[ signed char*->container::string ][ !!! *4* !!! ][ 124 ][ 27 ][ --- ]]
[[ iterator_range<char*>->char ][ !!! *<1* !!! ][ 103 ][ 13 ][ 8 ]]
[[ iterator_range<char*>->signed char ][ !!! *<1* !!! ][ 107 ][ 13 ][ 9 ]]
[[ iterator_range<char*>->unsigned char ][ !!! *<1* !!! ][ 121 ][ 26 ][ 13 ]]
[[ iterator_range<char*>->int ][ !!! *6* !!! ][ 165 ][ 33 ][ 23 ]]
[[ iterator_range<char*>->short ][ !!! *8* !!! ][ 175 ][ 34 ][ 29 ]]
[[ iterator_range<char*>->long int ][ !!! *14* !!! ][ 160 ][ 33 ][ 23 ]]
[[ iterator_range<char*>->long long ][ !!! *10* !!! ][ 199 ][ 35 ][ 28 ]]
[[ iterator_range<char*>->unsigned int ][ !!! *6* !!! ][ 131 ][ 24 ][ 16 ]]
[[ iterator_range<char*>->unsigned short ][ !!! *7* !!! ][ 110 ][ 22 ][ 16 ]]
[[ iterator_range<char*>->unsigned long int ][ !!! *7* !!! ][ 111 ][ 22 ][ 14 ]]
[[ iterator_range<char*>->unsigned long long ][ !!! *8* !!! ][ 115 ][ 24 ][ 15 ]]
[[ iterator_range<char*>->float ][ !!! *13* !!! ][ 134 ][ 40 ][ 33 ]]
[[ iterator_range<char*>->double ][ !!! *15* !!! ][ 140 ][ 59 ][ 41 ]]
[[ iterator_range<char*>->long double ][ 131 ][ 146 ][ 53 ][ !!! *38* !!! ]]
[[ iterator_range<char*>->string ][ !!! *9* !!! ][ 121 ][ 31 ][ --- ]]
[[ iterator_range<char*>->container::string ][ !!! *4* !!! ][ 115 ][ 25 ][ --- ]]
[[ int->int ][ !!! *<1* !!! ][ 113 ][ 25 ][ --- ]]
[[ float->double ][ !!! *<1* !!! ][ 234 ][ 117 ][ --- ]]
[[ char->signed char ][ !!! *<1* !!! ][ 97 ][ 9 ][ --- ]]
]
[endsect]
[section gcc-4.4][table:id Performance Table (gcc-4.4)
[section GNU C++ version 4.6.1]
[table:id Performance Table ( GNU C++ version 4.6.1)
[[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]]
[[ string->char ][ !!! *<1* !!! ][ 90 ][ 7 ][ 7 ]]
[[ string->signed char ][ !!! *<1* !!! ][ 88 ][ 7 ][ 8 ]]
[[ string->unsigned char ][ !!! *<1* !!! ][ 88 ][ 8 ][ 14 ]]
[[ string->int ][ !!! *3* !!! ][ 103 ][ 18 ][ 15 ]]
[[ string->short ][ !!! *3* !!! ][ 105 ][ 20 ][ 15 ]]
[[ string->long int ][ !!! *3* !!! ][ 101 ][ 18 ][ 16 ]]
[[ string->long long ][ !!! *3* !!! ][ 101 ][ 18 ][ 15 ]]
[[ string->unsigned int ][ !!! *3* !!! ][ 98 ][ 23 ][ 14 ]]
[[ string->unsigned short ][ !!! *3* !!! ][ 100 ][ 17 ][ 14 ]]
[[ string->unsigned long int ][ !!! *3* !!! ][ 100 ][ 21 ][ 15 ]]
[[ string->unsigned long long ][ !!! *3* !!! ][ 99 ][ 19 ][ 15 ]]
[[ string->bool ][ !!! *<1* !!! ][ 95 ][ 16 ][ 8 ]]
[[ string->float ][ !!! *13* !!! ][ 160 ][ 61 ][ 33 ]]
[[ string->double ][ !!! *14* !!! ][ 206 ][ 93 ][ 59 ]]
[[ string->long double ][ 128 ][ 217 ][ 96 ][ !!! *61* !!! ]]
[[ char->string ][ !!! *7* !!! ][ 100 ][ 17 ][ 12 ]]
[[ unsigned char->string ][ !!! *7* !!! ][ 109 ][ 17 ][ 16 ]]
[[ signed char->string ][ !!! *7* !!! ][ 99 ][ 17 ][ 12 ]]
[[ int->string ][ !!! *13* !!! ][ 110 ][ 21 ][ 15 ]]
[[ short->string ][ !!! *14* !!! ][ 110 ][ 22 ][ 17 ]]
[[ long int->string ][ !!! *14* !!! ][ 109 ][ 21 ][ 16 ]]
[[ long long->string ][ !!! *13* !!! ][ 114 ][ 20 ][ 17 ]]
[[ unsigned int->string ][ !!! *13* !!! ][ 109 ][ 23 ][ 15 ]]
[[ unsigned short->string ][ !!! *14* !!! ][ 109 ][ 23 ][ 17 ]]
[[ unsigned long int->string ][ !!! *13* !!! ][ 112 ][ 23 ][ 16 ]]
[[ unsigned long long->string ][ !!! *14* !!! ][ 109 ][ 21 ][ 17 ]]
[[ bool->string ][ !!! *7* !!! ][ 108 ][ 23 ][ 11 ]]
[[ float->string ][ 63 ][ 185 ][ 92 ][ !!! *50* !!! ]]
[[ double->string ][ 106 ][ 216 ][ 116 ][ !!! *75* !!! ]]
[[ long double->string ][ 118 ][ 219 ][ 119 ][ !!! *80* !!! ]]
[[ char*->char ][ !!! *1* !!! ][ 93 ][ 9 ][ 9 ]]
[[ char*->signed char ][ !!! *1* !!! ][ 92 ][ 9 ][ 9 ]]
[[ char*->unsigned char ][ !!! *1* !!! ][ 92 ][ 9 ][ 14 ]]
[[ char*->int ][ !!! *4* !!! ][ 107 ][ 19 ][ 15 ]]
[[ char*->short ][ !!! *5* !!! ][ 109 ][ 19 ][ 15 ]]
[[ char*->long int ][ !!! *4* !!! ][ 113 ][ 19 ][ 15 ]]
[[ char*->long long ][ !!! *4* !!! ][ 108 ][ 20 ][ 15 ]]
[[ char*->unsigned int ][ !!! *4* !!! ][ 106 ][ 19 ][ 15 ]]
[[ char*->unsigned short ][ !!! *4* !!! ][ 106 ][ 18 ][ 15 ]]
[[ char*->unsigned long int ][ !!! *4* !!! ][ 103 ][ 22 ][ 15 ]]
[[ char*->unsigned long long ][ !!! *4* !!! ][ 105 ][ 20 ][ 15 ]]
[[ char*->bool ][ !!! *1* !!! ][ 104 ][ 18 ][ 8 ]]
[[ char*->float ][ !!! *15* !!! ][ 164 ][ 62 ][ 33 ]]
[[ char*->double ][ !!! *16* !!! ][ 203 ][ 97 ][ 58 ]]
[[ char*->long double ][ 132 ][ 223 ][ 98 ][ !!! *60* !!! ]]
[[ unsigned char*->char ][ !!! *2* !!! ][ 90 ][ 9 ][ 8 ]]
[[ unsigned char*->signed char ][ !!! *2* !!! ][ 92 ][ 10 ][ 8 ]]
[[ unsigned char*->unsigned char ][ !!! *2* !!! ][ 91 ][ 9 ][ 14 ]]
[[ unsigned char*->int ][ !!! *6* !!! ][ 106 ][ 20 ][ 15 ]]
[[ unsigned char*->short ][ !!! *6* !!! ][ 106 ][ 21 ][ 15 ]]
[[ unsigned char*->long int ][ !!! *6* !!! ][ 111 ][ 19 ][ 15 ]]
[[ unsigned char*->long long ][ !!! *6* !!! ][ 107 ][ 20 ][ 15 ]]
[[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 105 ][ 19 ][ 15 ]]
[[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 103 ][ 18 ][ 15 ]]
[[ unsigned char*->unsigned long int ][ !!! *6* !!! ][ 106 ][ 22 ][ 14 ]]
[[ unsigned char*->unsigned long long ][ !!! *6* !!! ][ 105 ][ 20 ][ 14 ]]
[[ unsigned char*->bool ][ !!! *2* !!! ][ 106 ][ 18 ][ 8 ]]
[[ unsigned char*->float ][ !!! *15* !!! ][ 167 ][ 68 ][ 33 ]]
[[ unsigned char*->double ][ !!! *17* !!! ][ 203 ][ 99 ][ 58 ]]
[[ unsigned char*->long double ][ 129 ][ 216 ][ 97 ][ !!! *61* !!! ]]
[[ unsigned char*->string ][ !!! *13* !!! ][ 111 ][ 23 ][ --- ]]
[[ signed char*->char ][ !!! *2* !!! ][ 92 ][ 9 ][ 8 ]]
[[ signed char*->signed char ][ !!! *2* !!! ][ 91 ][ 9 ][ 8 ]]
[[ signed char*->unsigned char ][ !!! *2* !!! ][ 91 ][ 9 ][ 14 ]]
[[ signed char*->int ][ !!! *6* !!! ][ 107 ][ 19 ][ 15 ]]
[[ signed char*->short ][ !!! *6* !!! ][ 109 ][ 24 ][ 14 ]]
[[ signed char*->long int ][ !!! *6* !!! ][ 112 ][ 19 ][ 15 ]]
[[ signed char*->long long ][ !!! *5* !!! ][ 107 ][ 20 ][ 15 ]]
[[ signed char*->unsigned int ][ !!! *6* !!! ][ 108 ][ 20 ][ 15 ]]
[[ signed char*->unsigned short ][ !!! *6* !!! ][ 104 ][ 18 ][ 15 ]]
[[ signed char*->unsigned long int ][ !!! *6* !!! ][ 102 ][ 22 ][ 15 ]]
[[ signed char*->unsigned long long ][ !!! *6* !!! ][ 104 ][ 20 ][ 15 ]]
[[ signed char*->bool ][ !!! *2* !!! ][ 104 ][ 18 ][ 8 ]]
[[ signed char*->float ][ !!! *16* !!! ][ 165 ][ 63 ][ 33 ]]
[[ signed char*->double ][ !!! *16* !!! ][ 203 ][ 98 ][ 59 ]]
[[ signed char*->long double ][ 129 ][ 215 ][ 98 ][ !!! *61* !!! ]]
[[ signed char*->string ][ !!! *13* !!! ][ 109 ][ 21 ][ --- ]]
[[ int->int ][ !!! *<1* !!! ][ 109 ][ 21 ][ --- ]]
[[ float->double ][ !!! *<1* !!! ][ 221 ][ 102 ][ --- ]]
[[ double->double ][ !!! *<1* !!! ][ 223 ][ 103 ][ --- ]]
[[ int->int ][ !!! *<1* !!! ][ 231 ][ 115 ][ --- ]]
[[ int->int ][ !!! *<1* !!! ][ 231 ][ 115 ][ --- ]]
[[ char->unsigned char ][ !!! *<1* !!! ][ 92 ][ 8 ][ --- ]]
[[ char->signed char ][ !!! *<1* !!! ][ 88 ][ 8 ][ --- ]]
[[ unsigned char->char ][ !!! *<1* !!! ][ 88 ][ 7 ][ --- ]]
[[ signed char->char ][ !!! *<1* !!! ][ 89 ][ 8 ][ --- ]]
[[ string->char ][ !!! *<1* !!! ][ 140 ][ 17 ][ 13 ]]
[[ string->signed char ][ !!! *<1* !!! ][ 129 ][ 8 ][ 10 ]]
[[ string->unsigned char ][ !!! *<1* !!! ][ 91 ][ 8 ][ 10 ]]
[[ string->int ][ !!! *6* !!! ][ 110 ][ 20 ][ 14 ]]
[[ string->short ][ !!! *5* !!! ][ 106 ][ 20 ][ 14 ]]
[[ string->long int ][ !!! *7* !!! ][ 107 ][ 22 ][ 14 ]]
[[ string->long long ][ !!! *7* !!! ][ 112 ][ 21 ][ 14 ]]
[[ string->unsigned int ][ !!! *6* !!! ][ 110 ][ 20 ][ 14 ]]
[[ string->unsigned short ][ !!! *5* !!! ][ 107 ][ 18 ][ 14 ]]
[[ string->unsigned long int ][ !!! *7* !!! ][ 108 ][ 23 ][ 14 ]]
[[ string->unsigned long long ][ !!! *7* !!! ][ 108 ][ 21 ][ 14 ]]
[[ string->float ][ !!! *12* !!! ][ 154 ][ 57 ][ 32 ]]
[[ string->double ][ !!! *11* !!! ][ 151 ][ 61 ][ 33 ]]
[[ string->long double ][ 109 ][ 187 ][ 79 ][ !!! *55* !!! ]]
[[ string->string ][ !!! *2* !!! ][ 122 ][ 27 ][ --- ]]
[[ string->container::string ][ !!! *3* !!! ][ 123 ][ 22 ][ --- ]]
[[ string->char ][ !!! *7* !!! ][ 109 ][ 27 ][ 17 ]]
[[ string->signed char ][ !!! *7* !!! ][ 110 ][ 25 ][ 22 ]]
[[ string->unsigned char ][ !!! *7* !!! ][ 112 ][ 27 ][ 24 ]]
[[ int->string ][ !!! *12* !!! ][ 187 ][ 48 ][ 37 ]]
[[ short->string ][ !!! *18* !!! ][ 133 ][ 33 ][ 20 ]]
[[ long int->string ][ !!! *12* !!! ][ 129 ][ 32 ][ 21 ]]
[[ long long->string ][ !!! *12* !!! ][ 127 ][ 35 ][ 23 ]]
[[ unsigned int->string ][ !!! *15* !!! ][ 133 ][ 31 ][ 21 ]]
[[ unsigned short->string ][ !!! *12* !!! ][ 133 ][ 31 ][ 21 ]]
[[ unsigned long int->string ][ !!! *12* !!! ][ 132 ][ 31 ][ 21 ]]
[[ unsigned long long->string ][ !!! *12* !!! ][ 127 ][ 29 ][ 24 ]]
[[ float->string ][ 53 ][ 215 ][ 103 ][ !!! *40* !!! ]]
[[ double->string ][ 58 ][ 215 ][ 103 ][ !!! *41* !!! ]]
[[ long double->string ][ 67 ][ 227 ][ 112 ][ !!! *45* !!! ]]
[[ char*->char ][ !!! *<1* !!! ][ 132 ][ 12 ][ 8 ]]
[[ char*->signed char ][ !!! *<1* !!! ][ 98 ][ 11 ][ 9 ]]
[[ char*->unsigned char ][ !!! *<1* !!! ][ 96 ][ 10 ][ 9 ]]
[[ char*->int ][ !!! *6* !!! ][ 109 ][ 22 ][ 14 ]]
[[ char*->short ][ !!! *5* !!! ][ 109 ][ 26 ][ 14 ]]
[[ char*->long int ][ !!! *7* !!! ][ 111 ][ 23 ][ 14 ]]
[[ char*->long long ][ !!! *8* !!! ][ 112 ][ 25 ][ 16 ]]
[[ char*->unsigned int ][ !!! *6* !!! ][ 113 ][ 19 ][ 14 ]]
[[ char*->unsigned short ][ !!! *6* !!! ][ 111 ][ 20 ][ 14 ]]
[[ char*->unsigned long int ][ !!! *7* !!! ][ 109 ][ 21 ][ 14 ]]
[[ char*->unsigned long long ][ !!! *7* !!! ][ 111 ][ 22 ][ 14 ]]
[[ char*->float ][ !!! *12* !!! ][ 156 ][ 62 ][ 32 ]]
[[ char*->double ][ !!! *13* !!! ][ 156 ][ 65 ][ 33 ]]
[[ char*->long double ][ 108 ][ 156 ][ 59 ][ !!! *36* !!! ]]
[[ char*->string ][ !!! *7* !!! ][ 123 ][ 29 ][ --- ]]
[[ char*->container::string ][ !!! *2* !!! ][ 116 ][ 24 ][ --- ]]
[[ unsigned char*->char ][ !!! *<1* !!! ][ 96 ][ 12 ][ 8 ]]
[[ unsigned char*->signed char ][ !!! *<1* !!! ][ 97 ][ 9 ][ 9 ]]
[[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 93 ][ 10 ][ 9 ]]
[[ unsigned char*->int ][ !!! *6* !!! ][ 110 ][ 22 ][ 14 ]]
[[ unsigned char*->short ][ !!! *6* !!! ][ 111 ][ 22 ][ 15 ]]
[[ unsigned char*->long int ][ !!! *8* !!! ][ 110 ][ 23 ][ 14 ]]
[[ unsigned char*->long long ][ !!! *7* !!! ][ 111 ][ 25 ][ 14 ]]
[[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 111 ][ 21 ][ 16 ]]
[[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 110 ][ 21 ][ 15 ]]
[[ unsigned char*->unsigned long int ][ !!! *8* !!! ][ 114 ][ 21 ][ 14 ]]
[[ unsigned char*->unsigned long long ][ !!! *8* !!! ][ 108 ][ 23 ][ 15 ]]
[[ unsigned char*->float ][ !!! *12* !!! ][ 154 ][ 62 ][ 33 ]]
[[ unsigned char*->double ][ !!! *14* !!! ][ 157 ][ 65 ][ 32 ]]
[[ unsigned char*->long double ][ 107 ][ 154 ][ 56 ][ !!! *36* !!! ]]
[[ unsigned char*->string ][ !!! *9* !!! ][ 122 ][ 28 ][ --- ]]
[[ unsigned char*->container::string ][ !!! *4* !!! ][ 118 ][ 26 ][ --- ]]
[[ signed char*->char ][ !!! *<1* !!! ][ 94 ][ 10 ][ 8 ]]
[[ signed char*->signed char ][ !!! *<1* !!! ][ 94 ][ 12 ][ 9 ]]
[[ signed char*->unsigned char ][ !!! *<1* !!! ][ 95 ][ 12 ][ 9 ]]
[[ signed char*->int ][ !!! *7* !!! ][ 109 ][ 22 ][ 14 ]]
[[ signed char*->short ][ !!! *5* !!! ][ 108 ][ 22 ][ 14 ]]
[[ signed char*->long int ][ !!! *7* !!! ][ 110 ][ 23 ][ 14 ]]
[[ signed char*->long long ][ !!! *7* !!! ][ 110 ][ 25 ][ 15 ]]
[[ signed char*->unsigned int ][ !!! *6* !!! ][ 109 ][ 20 ][ 15 ]]
[[ signed char*->unsigned short ][ !!! *6* !!! ][ 107 ][ 21 ][ 14 ]]
[[ signed char*->unsigned long int ][ !!! *8* !!! ][ 111 ][ 21 ][ 14 ]]
[[ signed char*->unsigned long long ][ !!! *7* !!! ][ 109 ][ 23 ][ 14 ]]
[[ signed char*->float ][ !!! *12* !!! ][ 156 ][ 61 ][ 31 ]]
[[ signed char*->double ][ !!! *13* !!! ][ 156 ][ 68 ][ 33 ]]
[[ signed char*->long double ][ 109 ][ 159 ][ 56 ][ !!! *36* !!! ]]
[[ signed char*->string ][ !!! *9* !!! ][ 123 ][ 28 ][ --- ]]
[[ signed char*->container::string ][ !!! *4* !!! ][ 125 ][ 25 ][ --- ]]
[[ iterator_range<char*>->char ][ !!! *<1* !!! ][ 100 ][ 13 ][ 8 ]]
[[ iterator_range<char*>->signed char ][ !!! *<1* !!! ][ 98 ][ 14 ][ 9 ]]
[[ iterator_range<char*>->unsigned char ][ !!! *<1* !!! ][ 99 ][ 12 ][ 10 ]]
[[ iterator_range<char*>->int ][ !!! *6* !!! ][ 108 ][ 21 ][ 16 ]]
[[ iterator_range<char*>->short ][ !!! *5* !!! ][ 110 ][ 22 ][ 17 ]]
[[ iterator_range<char*>->long int ][ !!! *7* !!! ][ 107 ][ 22 ][ 15 ]]
[[ iterator_range<char*>->long long ][ !!! *7* !!! ][ 110 ][ 27 ][ 15 ]]
[[ iterator_range<char*>->unsigned int ][ !!! *6* !!! ][ 107 ][ 24 ][ 15 ]]
[[ iterator_range<char*>->unsigned short ][ !!! *5* !!! ][ 106 ][ 21 ][ 15 ]]
[[ iterator_range<char*>->unsigned long int ][ !!! *7* !!! ][ 110 ][ 21 ][ 16 ]]
[[ iterator_range<char*>->unsigned long long ][ !!! *7* !!! ][ 109 ][ 23 ][ 16 ]]
[[ iterator_range<char*>->float ][ !!! *11* !!! ][ 137 ][ 46 ][ 33 ]]
[[ iterator_range<char*>->double ][ !!! *11* !!! ][ 131 ][ 50 ][ 33 ]]
[[ iterator_range<char*>->long double ][ 107 ][ 136 ][ 44 ][ !!! *39* !!! ]]
[[ iterator_range<char*>->string ][ !!! *8* !!! ][ 117 ][ 32 ][ --- ]]
[[ iterator_range<char*>->container::string ][ !!! *3* !!! ][ 111 ][ 23 ][ --- ]]
[[ int->int ][ !!! *<1* !!! ][ 110 ][ 33 ][ --- ]]
[[ float->double ][ !!! *<1* !!! ][ 241 ][ 152 ][ --- ]]
[[ char->signed char ][ !!! *<1* !!! ][ 90 ][ 8 ][ --- ]]
]
[endsect]
[section gcc-4.5][table:id Performance Table (gcc-4.5)
[section GNU C++ version 4.5.4]
[table:id Performance Table ( GNU C++ version 4.5.4)
[[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]]
[[ string->char ][ !!! *<1* !!! ][ 91 ][ 8 ][ 7 ]]
[[ string->signed char ][ !!! *<1* !!! ][ 91 ][ 8 ][ 7 ]]
[[ string->unsigned char ][ !!! *<1* !!! ][ 90 ][ 8 ][ 13 ]]
[[ string->int ][ !!! *3* !!! ][ 100 ][ 20 ][ 14 ]]
[[ string->short ][ !!! *3* !!! ][ 106 ][ 20 ][ 14 ]]
[[ string->long int ][ !!! *3* !!! ][ 100 ][ 18 ][ 14 ]]
[[ string->long long ][ !!! *9* !!! ][ 100 ][ 18 ][ 15 ]]
[[ string->unsigned int ][ !!! *3* !!! ][ 97 ][ 20 ][ 14 ]]
[[ string->unsigned short ][ !!! *3* !!! ][ 102 ][ 17 ][ 14 ]]
[[ string->unsigned long int ][ !!! *3* !!! ][ 97 ][ 21 ][ 14 ]]
[[ string->unsigned long long ][ !!! *3* !!! ][ 97 ][ 19 ][ 14 ]]
[[ string->bool ][ !!! *<1* !!! ][ 95 ][ 16 ][ 7 ]]
[[ string->float ][ !!! *15* !!! ][ 157 ][ 63 ][ 32 ]]
[[ string->double ][ !!! *17* !!! ][ 203 ][ 95 ][ 59 ]]
[[ string->long double ][ 129 ][ 216 ][ 93 ][ !!! *58* !!! ]]
[[ char->string ][ !!! *8* !!! ][ 100 ][ 17 ][ 10 ]]
[[ unsigned char->string ][ !!! *8* !!! ][ 96 ][ 18 ][ 16 ]]
[[ signed char->string ][ !!! *8* !!! ][ 96 ][ 18 ][ 10 ]]
[[ int->string ][ !!! *14* !!! ][ 105 ][ 22 ][ 15 ]]
[[ short->string ][ !!! *14* !!! ][ 107 ][ 23 ][ 17 ]]
[[ long int->string ][ !!! *14* !!! ][ 109 ][ 22 ][ 17 ]]
[[ long long->string ][ !!! *14* !!! ][ 105 ][ 22 ][ 18 ]]
[[ unsigned int->string ][ !!! *14* !!! ][ 105 ][ 25 ][ 15 ]]
[[ unsigned short->string ][ !!! *15* !!! ][ 105 ][ 23 ][ 17 ]]
[[ unsigned long int->string ][ !!! *14* !!! ][ 109 ][ 24 ][ 17 ]]
[[ unsigned long long->string ][ !!! *14* !!! ][ 102 ][ 23 ][ 17 ]]
[[ bool->string ][ !!! *8* !!! ][ 104 ][ 23 ][ 12 ]]
[[ float->string ][ 66 ][ 181 ][ 92 ][ !!! *49* !!! ]]
[[ double->string ][ 107 ][ 215 ][ 120 ][ !!! *75* !!! ]]
[[ long double->string ][ 117 ][ 221 ][ 125 ][ !!! *79* !!! ]]
[[ char*->char ][ !!! *1* !!! ][ 89 ][ 9 ][ 7 ]]
[[ char*->signed char ][ !!! *1* !!! ][ 90 ][ 9 ][ 7 ]]
[[ char*->unsigned char ][ !!! *2* !!! ][ 90 ][ 9 ][ 13 ]]
[[ char*->int ][ !!! *7* !!! ][ 103 ][ 20 ][ 15 ]]
[[ char*->short ][ !!! *6* !!! ][ 102 ][ 29 ][ 14 ]]
[[ char*->long int ][ !!! *7* !!! ][ 101 ][ 20 ][ 15 ]]
[[ char*->long long ][ !!! *6* !!! ][ 102 ][ 20 ][ 14 ]]
[[ char*->unsigned int ][ !!! *6* !!! ][ 99 ][ 19 ][ 14 ]]
[[ char*->unsigned short ][ !!! *6* !!! ][ 101 ][ 18 ][ 14 ]]
[[ char*->unsigned long int ][ !!! *6* !!! ][ 102 ][ 22 ][ 14 ]]
[[ char*->unsigned long long ][ !!! *6* !!! ][ 101 ][ 21 ][ 14 ]]
[[ char*->bool ][ !!! *3* !!! ][ 98 ][ 18 ][ 7 ]]
[[ char*->float ][ !!! *18* !!! ][ 162 ][ 63 ][ 31 ]]
[[ char*->double ][ !!! *17* !!! ][ 203 ][ 96 ][ 58 ]]
[[ char*->long double ][ 135 ][ 214 ][ 98 ][ !!! *58* !!! ]]
[[ unsigned char*->char ][ !!! *2* !!! ][ 87 ][ 9 ][ 7 ]]
[[ unsigned char*->signed char ][ !!! *2* !!! ][ 87 ][ 9 ][ 7 ]]
[[ unsigned char*->unsigned char ][ !!! *3* !!! ][ 87 ][ 9 ][ 13 ]]
[[ unsigned char*->int ][ !!! *6* !!! ][ 105 ][ 20 ][ 14 ]]
[[ unsigned char*->short ][ !!! *6* !!! ][ 102 ][ 21 ][ 14 ]]
[[ unsigned char*->long int ][ !!! *6* !!! ][ 101 ][ 20 ][ 14 ]]
[[ unsigned char*->long long ][ !!! *6* !!! ][ 102 ][ 20 ][ 14 ]]
[[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 99 ][ 19 ][ 14 ]]
[[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 100 ][ 18 ][ 14 ]]
[[ unsigned char*->unsigned long int ][ !!! *6* !!! ][ 101 ][ 24 ][ 14 ]]
[[ unsigned char*->unsigned long long ][ !!! *6* !!! ][ 100 ][ 20 ][ 14 ]]
[[ unsigned char*->bool ][ !!! *3* !!! ][ 99 ][ 18 ][ 8 ]]
[[ unsigned char*->float ][ !!! *17* !!! ][ 164 ][ 64 ][ 32 ]]
[[ unsigned char*->double ][ !!! *18* !!! ][ 201 ][ 94 ][ 58 ]]
[[ unsigned char*->long double ][ 133 ][ 217 ][ 95 ][ !!! *60* !!! ]]
[[ unsigned char*->string ][ !!! *14* !!! ][ 103 ][ 23 ][ --- ]]
[[ signed char*->char ][ !!! *3* !!! ][ 88 ][ 10 ][ 8 ]]
[[ signed char*->signed char ][ !!! *2* !!! ][ 87 ][ 10 ][ 7 ]]
[[ signed char*->unsigned char ][ !!! *3* !!! ][ 87 ][ 9 ][ 13 ]]
[[ signed char*->int ][ !!! *6* !!! ][ 104 ][ 20 ][ 14 ]]
[[ signed char*->short ][ !!! *6* !!! ][ 105 ][ 21 ][ 14 ]]
[[ signed char*->long int ][ !!! *6* !!! ][ 104 ][ 20 ][ 15 ]]
[[ signed char*->long long ][ !!! *6* !!! ][ 106 ][ 20 ][ 14 ]]
[[ signed char*->unsigned int ][ !!! *6* !!! ][ 99 ][ 20 ][ 14 ]]
[[ signed char*->unsigned short ][ !!! *6* !!! ][ 100 ][ 18 ][ 14 ]]
[[ signed char*->unsigned long int ][ !!! *6* !!! ][ 102 ][ 23 ][ 14 ]]
[[ signed char*->unsigned long long ][ !!! *6* !!! ][ 103 ][ 20 ][ 14 ]]
[[ signed char*->bool ][ !!! *3* !!! ][ 99 ][ 18 ][ 7 ]]
[[ signed char*->float ][ !!! *18* !!! ][ 159 ][ 60 ][ 32 ]]
[[ signed char*->double ][ !!! *18* !!! ][ 203 ][ 95 ][ 57 ]]
[[ signed char*->long double ][ 129 ][ 213 ][ 97 ][ !!! *56* !!! ]]
[[ signed char*->string ][ !!! *14* !!! ][ 105 ][ 22 ][ --- ]]
[[ int->int ][ !!! *<1* !!! ][ 109 ][ 22 ][ --- ]]
[[ float->double ][ !!! *<1* !!! ][ 226 ][ 104 ][ --- ]]
[[ double->double ][ !!! *<1* !!! ][ 229 ][ 103 ][ --- ]]
[[ int->int ][ !!! *<1* !!! ][ 225 ][ 115 ][ --- ]]
[[ int->int ][ !!! *<1* !!! ][ 227 ][ 115 ][ --- ]]
[[ char->unsigned char ][ !!! *<1* !!! ][ 90 ][ 8 ][ --- ]]
[[ char->signed char ][ !!! *<1* !!! ][ 84 ][ 8 ][ --- ]]
[[ unsigned char->char ][ !!! *<1* !!! ][ 88 ][ 8 ][ --- ]]
[[ signed char->char ][ !!! *<1* !!! ][ 89 ][ 8 ][ --- ]]
[[ string->char ][ !!! *<1* !!! ][ 147 ][ 12 ][ 8 ]]
[[ string->signed char ][ !!! *<1* !!! ][ 138 ][ 13 ][ 10 ]]
[[ string->unsigned char ][ !!! *<1* !!! ][ 86 ][ 12 ][ 9 ]]
[[ string->int ][ !!! *7* !!! ][ 103 ][ 20 ][ 15 ]]
[[ string->short ][ !!! *5* !!! ][ 103 ][ 20 ][ 15 ]]
[[ string->long int ][ !!! *7* !!! ][ 103 ][ 22 ][ 15 ]]
[[ string->long long ][ !!! *7* !!! ][ 104 ][ 22 ][ 16 ]]
[[ string->unsigned int ][ !!! *6* !!! ][ 108 ][ 19 ][ 15 ]]
[[ string->unsigned short ][ !!! *5* !!! ][ 104 ][ 19 ][ 15 ]]
[[ string->unsigned long int ][ !!! *7* !!! ][ 103 ][ 20 ][ 16 ]]
[[ string->unsigned long long ][ !!! *7* !!! ][ 101 ][ 22 ][ 14 ]]
[[ string->float ][ !!! *13* !!! ][ 148 ][ 58 ][ 35 ]]
[[ string->double ][ !!! *13* !!! ][ 147 ][ 60 ][ 34 ]]
[[ string->long double ][ 103 ][ 149 ][ 56 ][ !!! *38* !!! ]]
[[ string->string ][ !!! *2* !!! ][ 127 ][ 27 ][ --- ]]
[[ string->container::string ][ !!! *3* !!! ][ 101 ][ 24 ][ --- ]]
[[ string->char ][ !!! *7* !!! ][ 108 ][ 35 ][ 17 ]]
[[ string->signed char ][ !!! *7* !!! ][ 112 ][ 26 ][ 23 ]]
[[ string->unsigned char ][ !!! *7* !!! ][ 113 ][ 25 ][ 25 ]]
[[ int->string ][ !!! *11* !!! ][ 183 ][ 47 ][ 40 ]]
[[ short->string ][ !!! *14* !!! ][ 153 ][ 35 ][ 23 ]]
[[ long int->string ][ !!! *12* !!! ][ 135 ][ 32 ][ 22 ]]
[[ long long->string ][ !!! *11* !!! ][ 131 ][ 30 ][ 24 ]]
[[ unsigned int->string ][ !!! *12* !!! ][ 137 ][ 31 ][ 22 ]]
[[ unsigned short->string ][ !!! *11* !!! ][ 137 ][ 33 ][ 22 ]]
[[ unsigned long int->string ][ !!! *11* !!! ][ 136 ][ 36 ][ 23 ]]
[[ unsigned long long->string ][ !!! *11* !!! ][ 127 ][ 29 ][ 23 ]]
[[ float->string ][ 56 ][ 218 ][ 107 ][ !!! *44* !!! ]]
[[ double->string ][ 63 ][ 223 ][ 106 ][ !!! *44* !!! ]]
[[ long double->string ][ 69 ][ 229 ][ 118 ][ !!! *49* !!! ]]
[[ char*->char ][ !!! *<1* !!! ][ 91 ][ 12 ][ 9 ]]
[[ char*->signed char ][ !!! *<1* !!! ][ 100 ][ 11 ][ 11 ]]
[[ char*->unsigned char ][ !!! *<1* !!! ][ 97 ][ 12 ][ 10 ]]
[[ char*->int ][ !!! *7* !!! ][ 112 ][ 23 ][ 16 ]]
[[ char*->short ][ !!! *6* !!! ][ 116 ][ 23 ][ 16 ]]
[[ char*->long int ][ !!! *8* !!! ][ 113 ][ 23 ][ 16 ]]
[[ char*->long long ][ !!! *8* !!! ][ 122 ][ 28 ][ 16 ]]
[[ char*->unsigned int ][ !!! *6* !!! ][ 117 ][ 21 ][ 15 ]]
[[ char*->unsigned short ][ !!! *6* !!! ][ 113 ][ 21 ][ 16 ]]
[[ char*->unsigned long int ][ !!! *7* !!! ][ 118 ][ 22 ][ 16 ]]
[[ char*->unsigned long long ][ !!! *8* !!! ][ 113 ][ 22 ][ 17 ]]
[[ char*->float ][ !!! *11* !!! ][ 164 ][ 67 ][ 34 ]]
[[ char*->double ][ !!! *13* !!! ][ 163 ][ 66 ][ 35 ]]
[[ char*->long double ][ 110 ][ 164 ][ 63 ][ !!! *39* !!! ]]
[[ char*->string ][ !!! *8* !!! ][ 130 ][ 30 ][ --- ]]
[[ char*->container::string ][ !!! *2* !!! ][ 113 ][ 24 ][ --- ]]
[[ unsigned char*->char ][ !!! *<1* !!! ][ 98 ][ 11 ][ 10 ]]
[[ unsigned char*->signed char ][ !!! *<1* !!! ][ 97 ][ 12 ][ 10 ]]
[[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 97 ][ 11 ][ 10 ]]
[[ unsigned char*->int ][ !!! *7* !!! ][ 112 ][ 23 ][ 16 ]]
[[ unsigned char*->short ][ !!! *6* !!! ][ 115 ][ 22 ][ 20 ]]
[[ unsigned char*->long int ][ !!! *8* !!! ][ 112 ][ 23 ][ 15 ]]
[[ unsigned char*->long long ][ !!! *8* !!! ][ 115 ][ 29 ][ 17 ]]
[[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 114 ][ 21 ][ 14 ]]
[[ unsigned char*->unsigned short ][ !!! *7* !!! ][ 112 ][ 22 ][ 15 ]]
[[ unsigned char*->unsigned long int ][ !!! *7* !!! ][ 115 ][ 23 ][ 14 ]]
[[ unsigned char*->unsigned long long ][ !!! *8* !!! ][ 112 ][ 24 ][ 15 ]]
[[ unsigned char*->float ][ !!! *12* !!! ][ 161 ][ 66 ][ 34 ]]
[[ unsigned char*->double ][ !!! *13* !!! ][ 162 ][ 66 ][ 36 ]]
[[ unsigned char*->long double ][ 112 ][ 161 ][ 63 ][ !!! *39* !!! ]]
[[ unsigned char*->string ][ !!! *9* !!! ][ 127 ][ 29 ][ --- ]]
[[ unsigned char*->container::string ][ !!! *4* !!! ][ 111 ][ 25 ][ --- ]]
[[ signed char*->char ][ !!! *<1* !!! ][ 104 ][ 11 ][ 8 ]]
[[ signed char*->signed char ][ !!! *<1* !!! ][ 98 ][ 11 ][ 11 ]]
[[ signed char*->unsigned char ][ !!! *<1* !!! ][ 98 ][ 11 ][ 11 ]]
[[ signed char*->int ][ !!! *7* !!! ][ 112 ][ 23 ][ 16 ]]
[[ signed char*->short ][ !!! *7* !!! ][ 113 ][ 23 ][ 15 ]]
[[ signed char*->long int ][ !!! *8* !!! ][ 112 ][ 22 ][ 14 ]]
[[ signed char*->long long ][ !!! *8* !!! ][ 115 ][ 25 ][ 16 ]]
[[ signed char*->unsigned int ][ !!! *8* !!! ][ 114 ][ 21 ][ 18 ]]
[[ signed char*->unsigned short ][ !!! *6* !!! ][ 112 ][ 22 ][ 15 ]]
[[ signed char*->unsigned long int ][ !!! *8* !!! ][ 116 ][ 22 ][ 15 ]]
[[ signed char*->unsigned long long ][ !!! *8* !!! ][ 113 ][ 23 ][ 16 ]]
[[ signed char*->float ][ !!! *13* !!! ][ 161 ][ 65 ][ 34 ]]
[[ signed char*->double ][ !!! *12* !!! ][ 172 ][ 67 ][ 34 ]]
[[ signed char*->long double ][ 110 ][ 164 ][ 63 ][ !!! *38* !!! ]]
[[ signed char*->string ][ !!! *9* !!! ][ 131 ][ 30 ][ --- ]]
[[ signed char*->container::string ][ !!! *4* !!! ][ 112 ][ 24 ][ --- ]]
[[ iterator_range<char*>->char ][ !!! *<1* !!! ][ 103 ][ 12 ][ 8 ]]
[[ iterator_range<char*>->signed char ][ !!! *<1* !!! ][ 101 ][ 13 ][ 9 ]]
[[ iterator_range<char*>->unsigned char ][ !!! *<1* !!! ][ 103 ][ 13 ][ 10 ]]
[[ iterator_range<char*>->int ][ !!! *7* !!! ][ 113 ][ 26 ][ 14 ]]
[[ iterator_range<char*>->short ][ !!! *5* !!! ][ 115 ][ 21 ][ 16 ]]
[[ iterator_range<char*>->long int ][ !!! *7* !!! ][ 115 ][ 22 ][ 15 ]]
[[ iterator_range<char*>->long long ][ !!! *7* !!! ][ 116 ][ 25 ][ 16 ]]
[[ iterator_range<char*>->unsigned int ][ !!! *6* !!! ][ 115 ][ 24 ][ 23 ]]
[[ iterator_range<char*>->unsigned short ][ !!! *5* !!! ][ 113 ][ 22 ][ 16 ]]
[[ iterator_range<char*>->unsigned long int ][ !!! *7* !!! ][ 117 ][ 20 ][ 16 ]]
[[ iterator_range<char*>->unsigned long long ][ !!! *7* !!! ][ 114 ][ 21 ][ 16 ]]
[[ iterator_range<char*>->float ][ !!! *11* !!! ][ 145 ][ 51 ][ 34 ]]
[[ iterator_range<char*>->double ][ !!! *11* !!! ][ 139 ][ 53 ][ 35 ]]
[[ iterator_range<char*>->long double ][ 109 ][ 147 ][ 44 ][ !!! *38* !!! ]]
[[ iterator_range<char*>->string ][ !!! *9* !!! ][ 123 ][ 36 ][ --- ]]
[[ iterator_range<char*>->container::string ][ !!! *3* !!! ][ 113 ][ 20 ][ --- ]]
[[ int->int ][ !!! *<1* !!! ][ 117 ][ 23 ][ --- ]]
[[ float->double ][ !!! *<1* !!! ][ 262 ][ 150 ][ --- ]]
[[ char->signed char ][ !!! *<1* !!! ][ 97 ][ 9 ][ --- ]]
]
[endsect]
[section gcc-4.6][table:id Performance Table (gcc-4.6)
[section GNU C++ version 4.4.6]
[table:id Performance Table ( GNU C++ version 4.4.6)
[[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]]
[[ string->char ][ !!! *<1* !!! ][ 94 ][ 8 ][ 7 ]]
[[ string->signed char ][ !!! *<1* !!! ][ 96 ][ 9 ][ 7 ]]
[[ string->unsigned char ][ !!! *<1* !!! ][ 96 ][ 8 ][ 13 ]]
[[ string->int ][ !!! *3* !!! ][ 110 ][ 18 ][ 16 ]]
[[ string->short ][ !!! *3* !!! ][ 111 ][ 18 ][ 16 ]]
[[ string->long int ][ !!! *3* !!! ][ 109 ][ 18 ][ 15 ]]
[[ string->long long ][ !!! *3* !!! ][ 111 ][ 18 ][ 15 ]]
[[ string->unsigned int ][ !!! *3* !!! ][ 110 ][ 20 ][ 15 ]]
[[ string->unsigned short ][ !!! *3* !!! ][ 111 ][ 18 ][ 15 ]]
[[ string->unsigned long int ][ !!! *3* !!! ][ 109 ][ 18 ][ 15 ]]
[[ string->unsigned long long ][ !!! *3* !!! ][ 114 ][ 19 ][ 15 ]]
[[ string->bool ][ !!! *<1* !!! ][ 106 ][ 17 ][ 8 ]]
[[ string->float ][ !!! *13* !!! ][ 175 ][ 70 ][ 33 ]]
[[ string->double ][ !!! *14* !!! ][ 182 ][ 81 ][ 58 ]]
[[ string->long double ][ 118 ][ 190 ][ 87 ][ !!! *58* !!! ]]
[[ char->string ][ !!! *8* !!! ][ 118 ][ 21 ][ 12 ]]
[[ unsigned char->string ][ !!! *8* !!! ][ 109 ][ 18 ][ 16 ]]
[[ signed char->string ][ !!! *8* !!! ][ 108 ][ 18 ][ 12 ]]
[[ int->string ][ 20 ][ 121 ][ 21 ][ !!! *16* !!! ]]
[[ short->string ][ !!! *15* !!! ][ 120 ][ 22 ][ 17 ]]
[[ long int->string ][ !!! *15* !!! ][ 120 ][ 22 ][ 16 ]]
[[ long long->string ][ !!! *15* !!! ][ 120 ][ 22 ][ 17 ]]
[[ unsigned int->string ][ !!! *15* !!! ][ 120 ][ 22 ][ 16 ]]
[[ unsigned short->string ][ !!! *15* !!! ][ 120 ][ 22 ][ 18 ]]
[[ unsigned long int->string ][ 16 ][ 118 ][ 22 ][ !!! *15* !!! ]]
[[ unsigned long long->string ][ !!! *15* !!! ][ 117 ][ 21 ][ 17 ]]
[[ bool->string ][ !!! *8* !!! ][ 117 ][ 23 ][ 10 ]]
[[ float->string ][ 77 ][ 218 ][ 105 ][ !!! *50* !!! ]]
[[ double->string ][ 108 ][ 247 ][ 129 ][ !!! *73* !!! ]]
[[ long double->string ][ 120 ][ 250 ][ 131 ][ !!! *79* !!! ]]
[[ char*->char ][ !!! *2* !!! ][ 99 ][ 9 ][ 7 ]]
[[ char*->signed char ][ !!! *2* !!! ][ 98 ][ 9 ][ 8 ]]
[[ char*->unsigned char ][ !!! *2* !!! ][ 98 ][ 9 ][ 13 ]]
[[ char*->int ][ !!! *6* !!! ][ 115 ][ 22 ][ 15 ]]
[[ char*->short ][ !!! *6* !!! ][ 114 ][ 22 ][ 15 ]]
[[ char*->long int ][ !!! *6* !!! ][ 114 ][ 22 ][ 16 ]]
[[ char*->long long ][ !!! *6* !!! ][ 119 ][ 22 ][ 15 ]]
[[ char*->unsigned int ][ !!! *6* !!! ][ 114 ][ 20 ][ 15 ]]
[[ char*->unsigned short ][ !!! *6* !!! ][ 116 ][ 20 ][ 15 ]]
[[ char*->unsigned long int ][ !!! *6* !!! ][ 117 ][ 22 ][ 15 ]]
[[ char*->unsigned long long ][ !!! *6* !!! ][ 118 ][ 22 ][ 15 ]]
[[ char*->bool ][ !!! *3* !!! ][ 113 ][ 18 ][ 8 ]]
[[ char*->float ][ !!! *15* !!! ][ 180 ][ 78 ][ 32 ]]
[[ char*->double ][ !!! *16* !!! ][ 185 ][ 89 ][ 58 ]]
[[ char*->long double ][ 119 ][ 193 ][ 91 ][ !!! *60* !!! ]]
[[ unsigned char*->char ][ !!! *2* !!! ][ 99 ][ 9 ][ 8 ]]
[[ unsigned char*->signed char ][ !!! *2* !!! ][ 99 ][ 10 ][ 8 ]]
[[ unsigned char*->unsigned char ][ !!! *2* !!! ][ 100 ][ 9 ][ 15 ]]
[[ unsigned char*->int ][ !!! *6* !!! ][ 118 ][ 22 ][ 15 ]]
[[ unsigned char*->short ][ !!! *6* !!! ][ 117 ][ 26 ][ 15 ]]
[[ unsigned char*->long int ][ !!! *6* !!! ][ 119 ][ 21 ][ 15 ]]
[[ unsigned char*->long long ][ !!! *6* !!! ][ 118 ][ 21 ][ 14 ]]
[[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 115 ][ 22 ][ 14 ]]
[[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 117 ][ 20 ][ 15 ]]
[[ unsigned char*->unsigned long int ][ !!! *6* !!! ][ 115 ][ 21 ][ 15 ]]
[[ unsigned char*->unsigned long long ][ !!! *6* !!! ][ 117 ][ 22 ][ 15 ]]
[[ unsigned char*->bool ][ !!! *3* !!! ][ 112 ][ 18 ][ 8 ]]
[[ unsigned char*->float ][ !!! *15* !!! ][ 181 ][ 78 ][ 33 ]]
[[ unsigned char*->double ][ !!! *16* !!! ][ 185 ][ 92 ][ 59 ]]
[[ unsigned char*->long double ][ 120 ][ 190 ][ 89 ][ !!! *58* !!! ]]
[[ unsigned char*->string ][ !!! *14* !!! ][ 121 ][ 22 ][ --- ]]
[[ signed char*->char ][ !!! *2* !!! ][ 99 ][ 9 ][ 9 ]]
[[ signed char*->signed char ][ !!! *2* !!! ][ 98 ][ 9 ][ 8 ]]
[[ signed char*->unsigned char ][ !!! *2* !!! ][ 98 ][ 9 ][ 14 ]]
[[ signed char*->int ][ !!! *6* !!! ][ 119 ][ 22 ][ 16 ]]
[[ signed char*->short ][ !!! *6* !!! ][ 115 ][ 22 ][ 15 ]]
[[ signed char*->long int ][ !!! *6* !!! ][ 119 ][ 22 ][ 15 ]]
[[ signed char*->long long ][ !!! *6* !!! ][ 117 ][ 22 ][ 15 ]]
[[ signed char*->unsigned int ][ !!! *6* !!! ][ 117 ][ 23 ][ 15 ]]
[[ signed char*->unsigned short ][ !!! *6* !!! ][ 117 ][ 21 ][ 14 ]]
[[ signed char*->unsigned long int ][ !!! *7* !!! ][ 119 ][ 24 ][ 15 ]]
[[ signed char*->unsigned long long ][ !!! *6* !!! ][ 116 ][ 22 ][ 15 ]]
[[ signed char*->bool ][ !!! *3* !!! ][ 111 ][ 18 ][ 8 ]]
[[ signed char*->float ][ !!! *16* !!! ][ 180 ][ 78 ][ 33 ]]
[[ signed char*->double ][ !!! *16* !!! ][ 185 ][ 89 ][ 59 ]]
[[ signed char*->long double ][ 120 ][ 191 ][ 91 ][ !!! *59* !!! ]]
[[ signed char*->string ][ !!! *14* !!! ][ 122 ][ 23 ][ --- ]]
[[ int->int ][ !!! *<1* !!! ][ 120 ][ 22 ][ --- ]]
[[ float->double ][ !!! *<1* !!! ][ 242 ][ 115 ][ --- ]]
[[ double->double ][ !!! *<1* !!! ][ 243 ][ 115 ][ --- ]]
[[ int->int ][ !!! *<1* !!! ][ 265 ][ 141 ][ --- ]]
[[ int->int ][ !!! *<1* !!! ][ 266 ][ 140 ][ --- ]]
[[ char->unsigned char ][ !!! *<1* !!! ][ 95 ][ 8 ][ --- ]]
[[ char->signed char ][ !!! *<1* !!! ][ 95 ][ 8 ][ --- ]]
[[ unsigned char->char ][ !!! *<1* !!! ][ 94 ][ 8 ][ --- ]]
[[ signed char->char ][ !!! *<1* !!! ][ 94 ][ 8 ][ --- ]]
[[ string->char ][ !!! *<1* !!! ][ 162 ][ 17 ][ 8 ]]
[[ string->signed char ][ !!! *<1* !!! ][ 103 ][ 9 ][ 9 ]]
[[ string->unsigned char ][ !!! *<1* !!! ][ 91 ][ 9 ][ 9 ]]
[[ string->int ][ !!! *6* !!! ][ 104 ][ 21 ][ 14 ]]
[[ string->short ][ !!! *5* !!! ][ 107 ][ 22 ][ 14 ]]
[[ string->long int ][ !!! *7* !!! ][ 106 ][ 23 ][ 15 ]]
[[ string->long long ][ !!! *7* !!! ][ 104 ][ 21 ][ 16 ]]
[[ string->unsigned int ][ !!! *6* !!! ][ 100 ][ 20 ][ 16 ]]
[[ string->unsigned short ][ !!! *5* !!! ][ 102 ][ 20 ][ 16 ]]
[[ string->unsigned long int ][ !!! *7* !!! ][ 106 ][ 25 ][ 16 ]]
[[ string->unsigned long long ][ !!! *7* !!! ][ 109 ][ 25 ][ 14 ]]
[[ string->float ][ !!! *13* !!! ][ 142 ][ 48 ][ 32 ]]
[[ string->double ][ !!! *13* !!! ][ 162 ][ 62 ][ 33 ]]
[[ string->long double ][ 119 ][ 164 ][ 62 ][ !!! *37* !!! ]]
[[ string->string ][ !!! *2* !!! ][ 122 ][ 27 ][ --- ]]
[[ string->container::string ][ !!! *2* !!! ][ 107 ][ 23 ][ --- ]]
[[ string->char ][ !!! *6* !!! ][ 110 ][ 24 ][ 15 ]]
[[ string->signed char ][ !!! *6* !!! ][ 107 ][ 24 ][ 21 ]]
[[ string->unsigned char ][ !!! *6* !!! ][ 106 ][ 27 ][ 21 ]]
[[ int->string ][ !!! *12* !!! ][ 122 ][ 31 ][ 21 ]]
[[ short->string ][ !!! *12* !!! ][ 136 ][ 29 ][ 20 ]]
[[ long int->string ][ !!! *12* !!! ][ 127 ][ 32 ][ 19 ]]
[[ long long->string ][ !!! *12* !!! ][ 121 ][ 32 ][ 21 ]]
[[ unsigned int->string ][ !!! *12* !!! ][ 133 ][ 32 ][ 19 ]]
[[ unsigned short->string ][ !!! *12* !!! ][ 126 ][ 33 ][ 20 ]]
[[ unsigned long int->string ][ !!! *11* !!! ][ 126 ][ 34 ][ 19 ]]
[[ unsigned long long->string ][ !!! *12* !!! ][ 125 ][ 28 ][ 21 ]]
[[ float->string ][ 47 ][ 183 ][ 86 ][ !!! *43* !!! ]]
[[ double->string ][ 57 ][ 184 ][ 90 ][ !!! *42* !!! ]]
[[ long double->string ][ 64 ][ 199 ][ 87 ][ !!! *46* !!! ]]
[[ char*->char ][ !!! *<1* !!! ][ 95 ][ 10 ][ 8 ]]
[[ char*->signed char ][ !!! *<1* !!! ][ 90 ][ 12 ][ 9 ]]
[[ char*->unsigned char ][ !!! *<1* !!! ][ 93 ][ 12 ][ 9 ]]
[[ char*->int ][ !!! *6* !!! ][ 108 ][ 24 ][ 14 ]]
[[ char*->short ][ !!! *6* !!! ][ 106 ][ 23 ][ 14 ]]
[[ char*->long int ][ !!! *7* !!! ][ 107 ][ 24 ][ 17 ]]
[[ char*->long long ][ !!! *7* !!! ][ 109 ][ 25 ][ 17 ]]
[[ char*->unsigned int ][ !!! *6* !!! ][ 104 ][ 23 ][ 17 ]]
[[ char*->unsigned short ][ !!! *6* !!! ][ 102 ][ 22 ][ 17 ]]
[[ char*->unsigned long int ][ !!! *7* !!! ][ 107 ][ 23 ][ 17 ]]
[[ char*->unsigned long long ][ !!! *7* !!! ][ 115 ][ 26 ][ 14 ]]
[[ char*->float ][ !!! *12* !!! ][ 150 ][ 56 ][ 30 ]]
[[ char*->double ][ !!! *12* !!! ][ 165 ][ 66 ][ 32 ]]
[[ char*->long double ][ 116 ][ 173 ][ 66 ][ !!! *37* !!! ]]
[[ char*->string ][ !!! *7* !!! ][ 120 ][ 28 ][ --- ]]
[[ char*->container::string ][ !!! *2* !!! ][ 108 ][ 26 ][ --- ]]
[[ unsigned char*->char ][ !!! *<1* !!! ][ 90 ][ 12 ][ 8 ]]
[[ unsigned char*->signed char ][ !!! *<1* !!! ][ 91 ][ 11 ][ 9 ]]
[[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 91 ][ 12 ][ 9 ]]
[[ unsigned char*->int ][ !!! *6* !!! ][ 106 ][ 24 ][ 14 ]]
[[ unsigned char*->short ][ !!! *6* !!! ][ 108 ][ 24 ][ 14 ]]
[[ unsigned char*->long int ][ !!! *7* !!! ][ 116 ][ 23 ][ 14 ]]
[[ unsigned char*->long long ][ !!! *7* !!! ][ 108 ][ 28 ][ 14 ]]
[[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 107 ][ 22 ][ 14 ]]
[[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 105 ][ 21 ][ 16 ]]
[[ unsigned char*->unsigned long int ][ !!! *7* !!! ][ 106 ][ 25 ][ 16 ]]
[[ unsigned char*->unsigned long long ][ !!! *7* !!! ][ 105 ][ 24 ][ 17 ]]
[[ unsigned char*->float ][ !!! *14* !!! ][ 150 ][ 57 ][ 33 ]]
[[ unsigned char*->double ][ !!! *14* !!! ][ 171 ][ 72 ][ 34 ]]
[[ unsigned char*->long double ][ 118 ][ 171 ][ 73 ][ !!! *38* !!! ]]
[[ unsigned char*->string ][ !!! *8* !!! ][ 120 ][ 29 ][ --- ]]
[[ unsigned char*->container::string ][ !!! *3* !!! ][ 114 ][ 26 ][ --- ]]
[[ signed char*->char ][ !!! *<1* !!! ][ 92 ][ 12 ][ 8 ]]
[[ signed char*->signed char ][ !!! *<1* !!! ][ 92 ][ 12 ][ 9 ]]
[[ signed char*->unsigned char ][ !!! *<1* !!! ][ 91 ][ 14 ][ 9 ]]
[[ signed char*->int ][ !!! *6* !!! ][ 109 ][ 22 ][ 15 ]]
[[ signed char*->short ][ !!! *6* !!! ][ 106 ][ 24 ][ 17 ]]
[[ signed char*->long int ][ !!! *7* !!! ][ 107 ][ 24 ][ 16 ]]
[[ signed char*->long long ][ !!! *7* !!! ][ 106 ][ 24 ][ 14 ]]
[[ signed char*->unsigned int ][ !!! *6* !!! ][ 106 ][ 22 ][ 14 ]]
[[ signed char*->unsigned short ][ !!! *6* !!! ][ 104 ][ 20 ][ 14 ]]
[[ signed char*->unsigned long int ][ !!! *7* !!! ][ 105 ][ 22 ][ 16 ]]
[[ signed char*->unsigned long long ][ !!! *7* !!! ][ 108 ][ 24 ][ 15 ]]
[[ signed char*->float ][ !!! *14* !!! ][ 147 ][ 54 ][ 32 ]]
[[ signed char*->double ][ !!! *14* !!! ][ 170 ][ 68 ][ 37 ]]
[[ signed char*->long double ][ 133 ][ 167 ][ 66 ][ !!! *37* !!! ]]
[[ signed char*->string ][ !!! *8* !!! ][ 119 ][ 30 ][ --- ]]
[[ signed char*->container::string ][ !!! *3* !!! ][ 108 ][ 24 ][ --- ]]
[[ iterator_range<char*>->char ][ !!! *<1* !!! ][ 98 ][ 13 ][ 8 ]]
[[ iterator_range<char*>->signed char ][ !!! *<1* !!! ][ 98 ][ 15 ][ 9 ]]
[[ iterator_range<char*>->unsigned char ][ !!! *<1* !!! ][ 97 ][ 15 ][ 9 ]]
[[ iterator_range<char*>->int ][ !!! *6* !!! ][ 107 ][ 27 ][ 14 ]]
[[ iterator_range<char*>->short ][ !!! *5* !!! ][ 109 ][ 23 ][ 14 ]]
[[ iterator_range<char*>->long int ][ !!! *7* !!! ][ 109 ][ 22 ][ 14 ]]
[[ iterator_range<char*>->long long ][ !!! *7* !!! ][ 107 ][ 24 ][ 14 ]]
[[ iterator_range<char*>->unsigned int ][ !!! *6* !!! ][ 120 ][ 23 ][ 14 ]]
[[ iterator_range<char*>->unsigned short ][ !!! *5* !!! ][ 104 ][ 21 ][ 17 ]]
[[ iterator_range<char*>->unsigned long int ][ !!! *8* !!! ][ 108 ][ 25 ][ 16 ]]
[[ iterator_range<char*>->unsigned long long ][ !!! *7* !!! ][ 106 ][ 25 ][ 15 ]]
[[ iterator_range<char*>->float ][ !!! *13* !!! ][ 132 ][ 41 ][ 32 ]]
[[ iterator_range<char*>->double ][ !!! *12* !!! ][ 136 ][ 45 ][ 32 ]]
[[ iterator_range<char*>->long double ][ 113 ][ 138 ][ 50 ][ !!! *36* !!! ]]
[[ iterator_range<char*>->string ][ !!! *7* !!! ][ 114 ][ 33 ][ --- ]]
[[ iterator_range<char*>->container::string ][ !!! *2* !!! ][ 105 ][ 24 ][ --- ]]
[[ int->int ][ !!! *<1* !!! ][ 112 ][ 31 ][ --- ]]
[[ float->double ][ !!! *<1* !!! ][ 233 ][ 199 ][ --- ]]
[[ char->signed char ][ !!! *<1* !!! ][ 129 ][ 10 ][ --- ]]
]
[endsect]
File diff suppressed because it is too large Load Diff
+20 -10
View File
@@ -100,17 +100,17 @@ void test_wallocator();
#endif
void test_char_types_conversions();
void operators_overload_test();
#ifndef BOOST_NO_CHAR16_T
#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS)
void test_char16_conversions();
#endif
#ifndef BOOST_NO_CHAR32_T
#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS)
void test_char32_conversions();
#endif
unit_test::test_suite *init_unit_test_suite(int, char *[])
{
unit_test_framework::test_suite *suite =
unit_test::test_suite *suite =
BOOST_TEST_SUITE("lexical_cast unit test");
suite->add(BOOST_TEST_CASE(test_conversion_to_char));
suite->add(BOOST_TEST_CASE(test_conversion_to_int));
@@ -149,10 +149,10 @@ unit_test::test_suite *init_unit_test_suite(int, char *[])
suite->add(BOOST_TEST_CASE(&test_char_types_conversions));
suite->add(BOOST_TEST_CASE(&operators_overload_test));
#ifndef BOOST_NO_CHAR16_T
#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS)
suite->add(BOOST_TEST_CASE(&test_char16_conversions));
#endif
#ifndef BOOST_NO_CHAR32_T
#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS)
suite->add(BOOST_TEST_CASE(&test_char32_conversions));
#endif
@@ -427,7 +427,6 @@ void test_conversion_to_wstring()
BOOST_CHECK(str == lexical_cast<std::wstring>(str));
BOOST_CHECK(L"123" == lexical_cast<std::wstring>(123));
BOOST_CHECK(L"1.23" == lexical_cast<std::wstring>(1.23));
BOOST_CHECK(L"1.111111111" == lexical_cast<std::wstring>(1.111111111));
BOOST_CHECK(L"1" == lexical_cast<std::wstring>(true));
BOOST_CHECK(L"0" == lexical_cast<std::wstring>(false));
#if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
@@ -756,12 +755,12 @@ void test_conversion_from_to_integral()
test_conversion_from_integral_to_char<T>(wzero);
test_conversion_from_char_to_integral<T>(wzero);
#endif
#ifndef BOOST_NO_CHAR16_T
#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS)
char16_t const u16zero = u'0';
test_conversion_from_integral_to_char<T>(u16zero);
test_conversion_from_char_to_integral<T>(u16zero);
#endif
#ifndef BOOST_NO_CHAR32_T
#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS)
char32_t const u32zero = u'0';
test_conversion_from_integral_to_char<T>(u32zero);
test_conversion_from_char_to_integral<T>(u32zero);
@@ -796,6 +795,17 @@ void test_conversion_from_to_integral()
BOOST_CHECK_THROW(lexical_cast<T>("+-9"), bad_lexical_cast);
// test_conversion_from_to_integral_for_locale
// Overflow test case from David W. Birdsall
std::string must_owerflow_str = "160000000000000000000";
std::string must_owerflow_negative_str = "-160000000000000000000";
for (int i = 0; i < 15; ++i) {
BOOST_CHECK_THROW(lexical_cast<T>(must_owerflow_str), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>(must_owerflow_negative_str), bad_lexical_cast);
must_owerflow_str += '0';
must_owerflow_negative_str += '0';
}
typedef std::numpunct<char> numpunct;
restore_oldloc guard;
@@ -1014,7 +1024,7 @@ void operators_overload_test()
}
#ifndef BOOST_NO_CHAR16_T
#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS)
void test_char16_conversions()
{
BOOST_CHECK(u"100" == lexical_cast<std::u16string>(u"100"));
@@ -1022,7 +1032,7 @@ void test_char16_conversions()
}
#endif
#ifndef BOOST_NO_CHAR32_T
#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS)
void test_char32_conversions()
{
BOOST_CHECK(U"100" == lexical_cast<std::u32string>(U"100"));
+29
View File
@@ -0,0 +1,29 @@
#==============================================================================
# Copyright (c) 2012 Antony Polukhin
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#==============================================================================
# performance tests
import testing ;
import path ;
path-constant TEST_DIR : . ;
project performance/test
: source-location ./
: requirements
# <library>/boost/chrono//boost_chrono
# <library>/boost/system//boost_system
<link>static
<target-os>freebsd:<linkflags>"-lrt"
<target-os>linux:<linkflags>"-lrt"
<toolset>gcc:<cxxflags>-fvisibility=hidden
<toolset>intel-linux:<cxxflags>-fvisibility=hidden
<toolset>sun:<cxxflags>-xldscope=hidden
: default-build release
;
run performance_test.cpp : $(TEST_DIR) ;
+324
View File
@@ -0,0 +1,324 @@
// (C) Copyright Antony Polukhin 2012.
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See http://www.boost.org/libs/config for most recent version.
//
// Testing lexical_cast<> performance
//
#define BOOST_ERROR_CODE_HEADER_ONLY
#define BOOST_CHRONO_HEADER_ONLY
#include <boost/lexical_cast.hpp>
#include <boost/chrono.hpp>
#include <fstream>
#include <cstring>
#include <boost/container/string.hpp>
// File to output data
std::fstream fout;
template <class OutT, class InT>
static inline void test_lexical(const InT& in_val) {
OutT out_val = boost::lexical_cast<OutT>(in_val);
(void)out_val;
}
template <class OutT, class InT>
static inline void test_ss_constr(const InT& in_val) {
OutT out_val;
std::stringstream ss;
ss << in_val;
if (ss.fail()) throw std::logic_error("descr");
ss >> out_val;
if (ss.fail()) throw std::logic_error("descr");
}
template <class OutT, class StringStreamT, class InT>
static inline void test_ss_noconstr(StringStreamT& ss, const InT& in_val) {
OutT out_val;
ss << in_val; // ss is an instance of std::stringstream
if (ss.fail()) throw std::logic_error("descr");
ss >> out_val;
if (ss.fail()) throw std::logic_error("descr");
/* reseting std::stringstream to use it again */
ss.str(std::string());
ss.clear();
}
struct structure_sprintf {
template <class OutT, class BufferT, class InT>
static inline void test(BufferT* buffer, const InT& in_val, const char* const conv) {
sprintf(buffer, conv, in_val);
OutT out_val(buffer);
}
template <class OutT, class BufferT>
static inline void test(BufferT* buffer, const std::string& in_val, const char* const conv) {
sprintf(buffer, conv, in_val.c_str());
OutT out_val(buffer);
}
};
struct structure_sscanf {
template <class OutT, class BufferT, class InT>
static inline void test(BufferT* /*buffer*/, const InT& in_val, const char* const conv) {
OutT out_val;
sscanf(reinterpret_cast<const char*>(in_val), conv, &out_val);
}
template <class OutT, class BufferT>
static inline void test(BufferT* /*buffer*/, const std::string& in_val, const char* const conv) {
OutT out_val;
sscanf(in_val.c_str(), conv, &out_val);
}
template <class OutT, class BufferT>
static inline void test(BufferT* /*buffer*/, const boost::iterator_range<const char*>& in_val, const char* const conv) {
OutT out_val;
sscanf(in_val.begin(), conv, &out_val);
}
};
struct structure_fake {
template <class OutT, class BufferT, class InT>
static inline void test(BufferT* /*buffer*/, const InT& /*in_val*/, const char* const /*conv*/) {}
};
static const int fake_test_value = 9999;
template <class T>
static inline void min_fancy_output(T v1, T v2, T v3, T v4) {
const char beg_mark[] = "!!! *";
const char end_mark[] = "* !!!";
const char no_mark[] = "";
unsigned int res = 4;
if (v1 < v2 && v1 < v3 && v1 < v4) res = 1;
if (v2 < v1 && v2 < v3 && v2 < v4) res = 2;
if (v3 < v1 && v3 < v2 && v3 < v4) res = 3;
fout << "[ "
<< (res == 1 ? beg_mark : no_mark)
;
if (v1) fout << v1;
else fout << "<1";
fout << (res == 1 ? end_mark : no_mark)
<< " ][ "
<< (res == 2 ? beg_mark : no_mark)
;
if (v2) fout << v2;
else fout << "<1";
fout << (res == 2 ? end_mark : no_mark)
<< " ][ "
<< (res == 3 ? beg_mark : no_mark)
;
if (v3) fout << v3;
else fout << "<1";
fout << (res == 3 ? end_mark : no_mark)
<< " ][ "
<< (res == 4 ? beg_mark : no_mark)
;
if (!v4) fout << "<1";
else if (v4 == fake_test_value) fout << "---";
else fout << v4;
fout
<< (res == 4 ? end_mark : no_mark)
<< " ]";
}
template <unsigned int IetartionsCountV, class ToT, class SprintfT, class FromT>
static inline void perf_test_impl(const FromT& in_val, const char* const conv) {
typedef boost::chrono::steady_clock test_clock;
test_clock::time_point start;
typedef boost::chrono::milliseconds duration_t;
duration_t lexical_cast_time, ss_constr_time, ss_noconstr_time, printf_time;
start = test_clock::now();
for (unsigned int i = 0; i < IetartionsCountV; ++i) {
test_lexical<ToT>(in_val);
test_lexical<ToT>(in_val);
test_lexical<ToT>(in_val);
test_lexical<ToT>(in_val);
}
lexical_cast_time = boost::chrono::duration_cast<duration_t>(test_clock::now() - start);
start = test_clock::now();
for (unsigned int i = 0; i < IetartionsCountV; ++i) {
test_ss_constr<ToT>(in_val);
test_ss_constr<ToT>(in_val);
test_ss_constr<ToT>(in_val);
test_ss_constr<ToT>(in_val);
}
ss_constr_time = boost::chrono::duration_cast<duration_t>(test_clock::now() - start);
std::stringstream ss;
start = test_clock::now();
for (unsigned int i = 0; i < IetartionsCountV; ++i) {
test_ss_noconstr<ToT>(ss, in_val);
test_ss_noconstr<ToT>(ss, in_val);
test_ss_noconstr<ToT>(ss, in_val);
test_ss_noconstr<ToT>(ss, in_val);
}
ss_noconstr_time = boost::chrono::duration_cast<duration_t>(test_clock::now() - start);
char buffer[128];
start = test_clock::now();
for (unsigned int i = 0; i < IetartionsCountV; ++i) {
SprintfT::template test<ToT>(buffer, in_val, conv);
SprintfT::template test<ToT>(buffer, in_val, conv);
SprintfT::template test<ToT>(buffer, in_val, conv);
SprintfT::template test<ToT>(buffer, in_val, conv);
}
printf_time = boost::chrono::duration_cast<duration_t>(test_clock::now() - start);
min_fancy_output(
lexical_cast_time.count(),
ss_constr_time.count(),
ss_noconstr_time.count(),
boost::is_same<SprintfT, structure_fake>::value ? fake_test_value : printf_time.count()
);
}
template <class ToT, class SprintfT, class FromT>
static inline void perf_test(const std::string& test_name, const FromT& in_val, const char* const conv) {
const unsigned int ITERATIONSCOUNT = 100000;
fout << " [[ " << test_name << " ]";
perf_test_impl<ITERATIONSCOUNT/4, ToT, SprintfT>(in_val, conv);
fout << "]\n";
}
template <class ConverterT>
void string_like_test_set(const std::string& from) {
typedef structure_sscanf ssc_t;
ConverterT conv;
perf_test<char, ssc_t>(from + "->char", conv("c"), "%c");
perf_test<signed char, ssc_t>(from + "->signed char", conv("c"), "%hhd");
perf_test<unsigned char, ssc_t>(from + "->unsigned char", conv("c"), "%hhu");
perf_test<int, ssc_t>(from + "->int", conv("100"), "%d");
perf_test<short, ssc_t>(from + "->short", conv("100"), "%hd");
perf_test<long int, ssc_t>(from + "->long int", conv("100"), "%ld");
perf_test<boost::long_long_type, ssc_t>(from + "->long long", conv("100"), "%lld");
perf_test<unsigned int, ssc_t>(from + "->unsigned int", conv("100"), "%u");
perf_test<unsigned short, ssc_t>(from + "->unsigned short", conv("100"), "%hu");
perf_test<unsigned long int, ssc_t>(from + "->unsigned long int", conv("100"), "%lu");
perf_test<boost::ulong_long_type, ssc_t>(from + "->unsigned long long", conv("100"), "%llu");
// perf_test<bool, ssc_t>(from + "->bool", conv("1"), "%");
perf_test<float, ssc_t>(from + "->float", conv("1.123"), "%f");
perf_test<double, ssc_t>(from + "->double", conv("1.123"), "%lf");
perf_test<long double, ssc_t>(from + "->long double", conv("1.123"), "%Lf");
perf_test<std::string, structure_fake>(from + "->string", conv("string"), "%Lf");
perf_test<boost::container::string, structure_fake>(from + "->container::string"
, conv("string"), "%Lf");
}
struct to_string_conv {
std::string operator()(const char* const c) const {
return c;
}
};
struct to_char_conv {
const char* operator()(const char* const c) const {
return c;
}
};
struct to_uchar_conv {
const unsigned char* operator()(const char* const c) const {
return reinterpret_cast<const unsigned char*>(c);
}
};
struct to_schar_conv {
const signed char* operator()(const char* const c) const {
return reinterpret_cast<const signed char*>(c);
}
};
struct to_iterator_range {
boost::iterator_range<const char*> operator()(const char* const c) const {
return boost::make_iterator_range(c, c + std::strlen(c));
}
};
int main(int argc, char** argv) {
BOOST_ASSERT(argc >= 2);
std::string output_path(argv[1]);
output_path += "/results.txt";
fout.open(output_path.c_str(), std::fstream::in | std::fstream::out | std::fstream::app);
BOOST_ASSERT(fout);
fout << "[section " << BOOST_COMPILER << "]\n"
<< "[table:id Performance Table ( "<< BOOST_COMPILER << ")\n"
<< "[[From->To] [lexical_cast] [std::stringstream with construction] "
<< "[std::stringstream without construction][scanf/printf]]\n";
// From std::string to ...
string_like_test_set<to_string_conv>("string");
// From ... to std::string
perf_test<std::string, structure_sprintf>("string->char", 'c', "%c");
perf_test<std::string, structure_sprintf>("string->signed char", static_cast<signed char>('c'), "%hhd");
perf_test<std::string, structure_sprintf>("string->unsigned char", static_cast<unsigned char>('c'), "%hhu");
perf_test<std::string, structure_sprintf>("int->string", 100, "%d");
perf_test<std::string, structure_sprintf>("short->string", static_cast<short>(100), "%hd");
perf_test<std::string, structure_sprintf>("long int->string", 100l, "%ld");
perf_test<std::string, structure_sprintf>("long long->string", 100ll, "%lld");
perf_test<std::string, structure_sprintf>("unsigned int->string", static_cast<unsigned short>(100u), "%u");
perf_test<std::string, structure_sprintf>("unsigned short->string", 100u, "%hu");
perf_test<std::string, structure_sprintf>("unsigned long int->string", 100ul, "%lu");
perf_test<std::string, structure_sprintf>("unsigned long long->string", static_cast<boost::ulong_long_type>(100), "%llu");
// perf_test<bool, structure_sscanf>("bool->string", std::string("1"), "%");
perf_test<std::string, structure_sprintf>("float->string", 1.123f, "%f");
perf_test<std::string, structure_sprintf>("double->string", 1.123, "%lf");
perf_test<std::string, structure_sprintf>("long double->string", 1.123L, "%Lf");
string_like_test_set<to_char_conv>("char*");
string_like_test_set<to_uchar_conv>("unsigned char*");
string_like_test_set<to_schar_conv>("signed char*");
string_like_test_set<to_iterator_range>("iterator_range<char*>");
perf_test<int, structure_fake>("int->int", 100, "");
perf_test<double, structure_fake>("float->double", 100.0f, "");
perf_test<signed char, structure_fake>("char->signed char", 'c', "");
fout << "]\n"
<< "[endsect]\n\n";
return 0;
}
+41 -24
View File
@@ -1,34 +1,51 @@
# Signals library
# Copyright (C) 2001-2003 Douglas Gregor
# Copyright (C) 2011-2012 Antony Polukhin
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
# Permission to copy, use, sell and distribute this software is granted
# provided this copyright notice appears in all copies. Permission to modify
# the code and to distribute modified code is granted provided this copyright
# notice appears in all copies, and a notice that the code was modified is
# included with the copyright notice. This software is provided "as is"
# without express or implied warranty, and with no claim as to its suitability
# for any purpose.
# For more information, see http://www.boost.org/
# bring in rules for testing
import testing ;
import feature ;
project
: requirements
<library>/boost/test//boost_unit_test_framework
<link>static
<toolset>gcc-4.8:<define>BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES
;
# Thanks to Steven Watanabe for helping with <nowchar> feature
feature.feature nowchar : on :
composite optional propagated link-incompatible ;
feature.compose <nowchar>on : <cxxflags>/Zc:wchar_t- ;
test-suite conversion
: [ run implicit_cast.cpp ]
[ compile-fail implicit_cast_fail.cpp ]
[ run ../cast_test.cpp ]
[ run ../numeric_cast_test.cpp ]
[ run ../lexical_cast_test.cpp ../../test/build//boost_unit_test_framework/<link>static ]
[ run lexical_cast_loopback_test.cpp ../../test/build//boost_unit_test_framework/<link>static ]
[ run lexical_cast_abstract_test.cpp ../../test/build//boost_unit_test_framework/<link>static ]
[ run lexical_cast_noncopyable_test.cpp ../../test/build//boost_unit_test_framework/<link>static ]
[ run lexical_cast_vc8_bug_test.cpp ../../test/build//boost_unit_test_framework/<link>static ]
[ run lexical_cast_wchars_test.cpp ../../test/build//boost_unit_test_framework/<link>static ]
[ run lexical_cast_float_types_test.cpp ../../test/build//boost_unit_test_framework/<link>static ]
[ run lexical_cast_inf_nan_test.cpp ../../test/build//boost_unit_test_framework/<link>static ]
[ run lexical_cast_empty_input_test.cpp ../../test/build//boost_unit_test_framework/<link>static ]
[ run ../numeric_cast_test.cpp ]
[ run ../lexical_cast_test.cpp ]
[ run lexical_cast_loopback_test.cpp ]
[ run lexical_cast_abstract_test.cpp ]
[ run lexical_cast_noncopyable_test.cpp ]
[ run lexical_cast_vc8_bug_test.cpp ]
[ run lexical_cast_wchars_test.cpp ]
[ run lexical_cast_float_types_test.cpp ]
[ run lexical_cast_inf_nan_test.cpp ]
[ run lexical_cast_containers_test.cpp ]
[ run lexical_cast_empty_input_test.cpp ]
[ run lexical_cast_pointers_test.cpp ]
[ compile lexical_cast_typedefed_wchar_test.cpp : <toolset>msvc:<nowchar>on ]
[ run lexical_cast_typedefed_wchar_test_runtime.cpp : : : <toolset>msvc:<nowchar>on <toolset>msvc,<stdlib>stlport:<build>no ]
[ run lexical_cast_no_locale_test.cpp : : : <define>BOOST_NO_STD_LOCALE <define>BOOST_LEXICAL_CAST_ASSUME_C_LOCALE ]
[ run lexical_cast_no_exceptions_test.cpp : : : <define>BOOST_NO_EXCEPTIONS
<toolset>gcc-4.3:<cflags>-fno-exceptions
<toolset>gcc-4.4:<cflags>-fno-exceptions
<toolset>gcc-4.5:<cflags>-fno-exceptions
<toolset>gcc-4.6:<cflags>-fno-exceptions
<toolset>gcc-4.7:<cflags>-fno-exceptions
]
[ run lexical_cast_iterator_range_test.cpp ]
;
+6
View File
@@ -28,5 +28,11 @@ int main()
type<foo> f = check_return(boost::implicit_cast<foo>("hello"));
type<long> z = check_return(boost::implicit_cast<long>(foo("hello")));
// warning supression:
(void)x;
(void)f;
(void)z;
return boost::report_errors();
}
+1 -1
View File
@@ -28,7 +28,7 @@ void test_abstract();
unit_test::test_suite *init_unit_test_suite(int, char *[])
{
unit_test_framework::test_suite *suite =
unit_test::test_suite *suite =
BOOST_TEST_SUITE("lexical_cast unit test");
suite->add(BOOST_TEST_CASE(&test_abstract));
+83
View File
@@ -0,0 +1,83 @@
// Testing boost::lexical_cast with boost::container::string.
//
// See http://www.boost.org for most recent version, including documentation.
//
// Copyright Antony Polukhin, 2011.
//
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
#include <boost/lexical_cast.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/container/string.hpp>
void testing_boost_containers_basic_string();
void testing_boost_containers_string_std_string();
void testing_boost_containers_string_widening();
using namespace boost;
boost::unit_test::test_suite *init_unit_test_suite(int, char *[])
{
unit_test::test_suite *suite =
BOOST_TEST_SUITE("Testing boost::lexical_cast with boost::container::string");
suite->add(BOOST_TEST_CASE(testing_boost_containers_basic_string));
suite->add(BOOST_TEST_CASE(testing_boost_containers_string_std_string));
suite->add(BOOST_TEST_CASE(testing_boost_containers_string_widening));
return suite;
}
void testing_boost_containers_basic_string()
{
BOOST_CHECK("100" == lexical_cast<boost::container::string>("100"));
BOOST_CHECK(L"100" == lexical_cast<boost::container::wstring>(L"100"));
BOOST_CHECK("100" == lexical_cast<boost::container::string>(100));
boost::container::string str("1000");
BOOST_CHECK(1000 == lexical_cast<int>(str));
}
#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING)
#define BOOST_LCAST_NO_WCHAR_T
#endif
void testing_boost_containers_string_std_string()
{
std::string std_str("std_str");
boost::container::string boost_str("boost_str");
BOOST_CHECK(boost::lexical_cast<std::string>(boost_str) == "boost_str");
BOOST_CHECK(boost::lexical_cast<boost::container::string>(std_str) == "std_str");
#ifndef BOOST_LCAST_NO_WCHAR_T
std::wstring std_wstr(L"std_wstr");
boost::container::wstring boost_wstr(L"boost_wstr");
BOOST_CHECK(boost::lexical_cast<std::wstring>(boost_wstr) == L"boost_wstr");
BOOST_CHECK(boost::lexical_cast<boost::container::wstring>(std_wstr) == L"std_wstr");
#endif
}
void testing_boost_containers_string_widening()
{
const char char_array[] = "Test string";
#ifndef BOOST_LCAST_NO_WCHAR_T
const wchar_t wchar_array[] = L"Test string";
BOOST_CHECK(boost::lexical_cast<boost::container::wstring>(char_array) == wchar_array);
#endif
#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS) && defined(BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES)
const char16_t char16_array[] = u"Test string";
BOOST_CHECK(boost::lexical_cast<boost::container::basic_string<char16_t> >(char_array) == char16_array);
#endif
#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS) && defined(BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES)
const char32_t char32_array[] = U"Test string";
BOOST_CHECK(boost::lexical_cast<boost::container::basic_string<char32_t> >(char_array) == char32_array);
#endif
}
+119 -12
View File
@@ -22,37 +22,144 @@
using namespace boost;
void test_empty_iterator_range()
#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING)
#define BOOST_LCAST_NO_WCHAR_T
#endif
template <class T>
void do_test_on_empty_input(T& v)
{
boost::iterator_range<const char*> v;
BOOST_CHECK_THROW(lexical_cast<int>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<float>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<double>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<long double>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<unsigned int>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<std::string>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<unsigned short>(v), bad_lexical_cast);
#if defined(BOOST_HAS_LONG_LONG)
BOOST_CHECK_THROW(lexical_cast<boost::ulong_long_type>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<boost::long_long_type>(v), bad_lexical_cast);
#elif defined(BOOST_HAS_MS_INT64)
BOOST_CHECK_THROW(lexical_cast<unsigned __int64>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<__int64>(v), bad_lexical_cast);
#endif
}
void test_empty_iterator_range()
{
boost::iterator_range<char*> v;
do_test_on_empty_input(v);
BOOST_CHECK_EQUAL(lexical_cast<std::string>(v), std::string());
BOOST_CHECK_THROW(lexical_cast<char>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<unsigned char>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<signed char>(v), bad_lexical_cast);
boost::iterator_range<const char*> cv;
do_test_on_empty_input(cv);
BOOST_CHECK_EQUAL(lexical_cast<std::string>(cv), std::string());
BOOST_CHECK_THROW(lexical_cast<char>(cv), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<unsigned char>(cv), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<signed char>(cv), bad_lexical_cast);
const boost::iterator_range<const char*> ccv;
do_test_on_empty_input(ccv);
BOOST_CHECK_EQUAL(lexical_cast<std::string>(ccv), std::string());
BOOST_CHECK_THROW(lexical_cast<char>(ccv), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<unsigned char>(ccv), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<signed char>(ccv), bad_lexical_cast);
}
void test_empty_string()
{
BOOST_CHECK_THROW(lexical_cast<int>(std::string()), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<float>(std::string()), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<double>(std::string()), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<long double>(std::string()), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<unsigned int>(std::string()), bad_lexical_cast);
BOOST_CHECK_EQUAL(lexical_cast<std::string>(std::string()), std::string());
BOOST_CHECK_THROW(lexical_cast<unsigned short>(std::string()), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<char>(std::string()), bad_lexical_cast);
std::string v;
do_test_on_empty_input(v);
BOOST_CHECK_THROW(lexical_cast<char>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<unsigned char>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<signed char>(v), bad_lexical_cast);
#ifndef BOOST_LCAST_NO_WCHAR_T
std::wstring vw;
do_test_on_empty_input(vw);
BOOST_CHECK_THROW(lexical_cast<wchar_t>(vw), bad_lexical_cast);
#endif
// Currently, no compiler and STL library fully support char16_t and char32_t
//#ifndef BOOST_NO_CHAR16_T
// std::basic_string<char16_t> v16w;
// do_test_on_empty_input(v16w);
// BOOST_CHECK_THROW(lexical_cast<char16_t>(v16w), bad_lexical_cast);
//#endif
//#ifndef BOOST_NO_CHAR32_T
// std::basic_string<char32_t> v32w;
// do_test_on_empty_input(v32w);
// BOOST_CHECK_THROW(lexical_cast<char32_t>(v32w), bad_lexical_cast);
//#endif
}
struct Escape
{
Escape(const std::string& s)
: str_(s)
{}
std::string str_;
};
inline std::ostream& operator<< (std::ostream& o, const Escape& rhs)
{
return o << rhs.str_;
}
void test_empty_user_class()
{
Escape v("");
do_test_on_empty_input(v);
BOOST_CHECK_THROW(lexical_cast<char>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<unsigned char>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<signed char>(v), bad_lexical_cast);
}
namespace std {
inline std::ostream & operator<<(std::ostream & out, const std::vector<long> & v)
{
std::ostream_iterator<long> it(out);
std::copy(v.begin(), v.end(), it);
assert(out);
return out;
}
}
void test_empty_vector()
{
std::vector<long> v;
do_test_on_empty_input(v);
BOOST_CHECK_THROW(lexical_cast<char>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<unsigned char>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<signed char>(v), bad_lexical_cast);
}
struct my_string {
friend std::ostream &operator<<(std::ostream& sout, my_string const&/* st*/) {
return sout << "";
}
};
void test_empty_zero_terminated_string()
{
my_string st;
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(st), std::string());;
}
unit_test::test_suite *init_unit_test_suite(int, char *[])
{
unit_test_framework::test_suite *suite =
unit_test::test_suite *suite =
BOOST_TEST_SUITE("lexical_cast. Empty input unit test");
suite->add(BOOST_TEST_CASE(&test_empty_iterator_range));
suite->add(BOOST_TEST_CASE(&test_empty_string));
suite->add(BOOST_TEST_CASE(&test_empty_user_class));
suite->add(BOOST_TEST_CASE(&test_empty_vector));
suite->add(BOOST_TEST_CASE(&test_empty_zero_terminated_string));
return suite;
}
+4 -2
View File
@@ -31,7 +31,7 @@ using namespace boost;
unit_test::test_suite *init_unit_test_suite(int, char *[])
{
unit_test_framework::test_suite *suite =
unit_test::test_suite *suite =
BOOST_TEST_SUITE("lexical_cast float types unit test");
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_float));
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_double));
@@ -237,7 +237,7 @@ void test_converion_to_float_types()
CHECK_CLOSE_ABS_DIFF(-10101.0E-011, test_t);
CHECK_CLOSE_ABS_DIFF(-10101093, test_t);
CHECK_CLOSE_ABS_DIFF(10101093, test_t);
CHECK_CLOSE_ABS_DIFF(-.34, test_t);
CHECK_CLOSE_ABS_DIFF(.34, test_t);
CHECK_CLOSE_ABS_DIFF(.34e10, test_t);
@@ -261,6 +261,7 @@ void test_converion_to_float_types()
BOOST_CHECK_THROW(lexical_cast<test_t>(".e"), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<test_t>(".11111111111111111111111111111111111111111111111111111111111111111111ee"), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<test_t>(".11111111111111111111111111111111111111111111111111111111111111111111e-"), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<test_t>("."), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<test_t>("-B"), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<test_t>("0xB"), bad_lexical_cast);
@@ -276,6 +277,7 @@ void test_converion_to_float_types()
BOOST_CHECK_THROW(lexical_cast<test_t>("-"), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<test_t>('\0'), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<test_t>('-'), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<test_t>('.'), bad_lexical_cast);
}
template <class T>
+22 -1
View File
@@ -85,6 +85,12 @@ void test_inf_nan_templated()
BOOST_CHECK( is_pos_inf( lexical_cast<test_t>("+infinity") ) );
BOOST_CHECK( is_pos_inf( lexical_cast<test_t>("+INFINITY") ) );
BOOST_CHECK( is_pos_inf( lexical_cast<test_t>("iNfiNity") ) );
BOOST_CHECK( is_pos_inf( lexical_cast<test_t>("INfinity") ) );
BOOST_CHECK( is_neg_inf( lexical_cast<test_t>("-inFINITY") ) );
BOOST_CHECK( is_neg_inf( lexical_cast<test_t>("-INFINITY") ) );
BOOST_CHECK( is_pos_nan( lexical_cast<test_t>("nan") ) );
BOOST_CHECK( is_pos_nan( lexical_cast<test_t>("NAN") ) );
@@ -94,6 +100,15 @@ void test_inf_nan_templated()
BOOST_CHECK( is_pos_nan( lexical_cast<test_t>("+nan") ) );
BOOST_CHECK( is_pos_nan( lexical_cast<test_t>("+NAN") ) );
BOOST_CHECK( is_pos_nan( lexical_cast<test_t>("nAn") ) );
BOOST_CHECK( is_pos_nan( lexical_cast<test_t>("NaN") ) );
BOOST_CHECK( is_neg_nan( lexical_cast<test_t>("-nAn") ) );
BOOST_CHECK( is_neg_nan( lexical_cast<test_t>("-NaN") ) );
BOOST_CHECK( is_pos_nan( lexical_cast<test_t>("+Nan") ) );
BOOST_CHECK( is_pos_nan( lexical_cast<test_t>("+nAN") ) );
BOOST_CHECK( is_pos_nan( lexical_cast<test_t>("nan()") ) );
BOOST_CHECK( is_pos_nan( lexical_cast<test_t>("NAN(some string)") ) );
BOOST_CHECK_THROW( lexical_cast<test_t>("NAN(some string"), bad_lexical_cast );
@@ -127,6 +142,12 @@ void test_inf_nan_templated()
BOOST_CHECK( is_pos_inf( lexical_cast<test_t>(L"+infinity") ) );
BOOST_CHECK( is_pos_inf( lexical_cast<test_t>(L"+INFINITY") ) );
BOOST_CHECK( is_neg_inf( lexical_cast<test_t>(L"-infINIty") ) );
BOOST_CHECK( is_neg_inf( lexical_cast<test_t>(L"-INFiniTY") ) );
BOOST_CHECK( is_pos_inf( lexical_cast<test_t>(L"+inFINIty") ) );
BOOST_CHECK( is_pos_inf( lexical_cast<test_t>(L"+INfinITY") ) );
BOOST_CHECK( is_pos_nan( lexical_cast<test_t>(L"nan") ) );
BOOST_CHECK( is_pos_nan( lexical_cast<test_t>(L"NAN") ) );
@@ -170,7 +191,7 @@ void test_inf_nan_long_double()
unit_test::test_suite *init_unit_test_suite(int, char *[])
{
unit_test_framework::test_suite *suite =
unit_test::test_suite *suite =
BOOST_TEST_SUITE("lexical_cast inf anf nan parsing unit test");
suite->add(BOOST_TEST_CASE(&test_inf_nan_float));
suite->add(BOOST_TEST_CASE(&test_inf_nan_double));
+217
View File
@@ -0,0 +1,217 @@
// Unit test for boost::lexical_cast.
//
// See http://www.boost.org for most recent version, including documentation.
//
// Copyright Antony Polukhin, 2012.
//
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
#include <boost/config.hpp>
#if defined(__INTEL_COMPILER)
#pragma warning(disable: 193 383 488 981 1418 1419)
#elif defined(BOOST_MSVC)
#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800)
#endif
#include <boost/lexical_cast.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/range/iterator_range.hpp>
using namespace boost;
#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING)
#define BOOST_LCAST_NO_WCHAR_T
#endif
struct class_with_user_defined_sream_operators {
int i;
operator int() const {
return i;
}
};
template <class CharT>
inline std::basic_istream<CharT>& operator >> (std::basic_istream<CharT>& istr, class_with_user_defined_sream_operators& rhs)
{
return istr >> rhs.i;
}
template <class RngT>
void do_test_iterator_range_impl(const RngT& rng)
{
BOOST_CHECK_EQUAL(lexical_cast<int>(rng), 1);
BOOST_CHECK_EQUAL(lexical_cast<unsigned int>(rng), 1u);
BOOST_CHECK_EQUAL(lexical_cast<short>(rng), 1);
BOOST_CHECK_EQUAL(lexical_cast<unsigned short>(rng), 1u);
BOOST_CHECK_EQUAL(lexical_cast<long int>(rng), 1);
BOOST_CHECK_EQUAL(lexical_cast<unsigned long int>(rng), 1u);
#ifdef BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES
BOOST_CHECK_EQUAL(lexical_cast<float>(rng), 1.0f);
BOOST_CHECK_EQUAL(lexical_cast<double>(rng), 1.0);
BOOST_CHECK_EQUAL(lexical_cast<long double>(rng), 1.0L);
BOOST_CHECK_EQUAL(lexical_cast<class_with_user_defined_sream_operators>(rng), 1);
#endif
#if defined(BOOST_HAS_LONG_LONG)
BOOST_CHECK_EQUAL(lexical_cast<boost::ulong_long_type>(rng), 1u);
BOOST_CHECK_EQUAL(lexical_cast<boost::long_long_type>(rng), 1);
#elif defined(BOOST_HAS_MS_INT64)
BOOST_CHECK_EQUAL(lexical_cast<unsigned __int64>(rng), 1u);
BOOST_CHECK_EQUAL(lexical_cast<__int64>(rng), 1);
#endif
}
template <class CharT>
void test_it_range_using_any_chars(CharT* one, CharT* eleven)
{
typedef CharT test_char_type;
// Zero terminated
iterator_range<test_char_type*> rng1(one, one + 1);
do_test_iterator_range_impl(rng1);
iterator_range<const test_char_type*> crng1(one, one + 1);
do_test_iterator_range_impl(crng1);
// Non zero terminated
iterator_range<test_char_type*> rng2(eleven, eleven + 1);
do_test_iterator_range_impl(rng2);
iterator_range<const test_char_type*> crng2(eleven, eleven + 1);
do_test_iterator_range_impl(crng2);
}
template <class CharT>
void test_it_range_using_char(CharT* one, CharT* eleven)
{
typedef CharT test_char_type;
iterator_range<test_char_type*> rng1(one, one + 1);
BOOST_CHECK_EQUAL(lexical_cast<std::string>(rng1), "1");
iterator_range<const test_char_type*> crng1(one, one + 1);
BOOST_CHECK_EQUAL(lexical_cast<std::string>(crng1), "1");
iterator_range<test_char_type*> rng2(eleven, eleven + 1);
BOOST_CHECK_EQUAL(lexical_cast<std::string>(rng2), "1");
iterator_range<const test_char_type*> crng2(eleven, eleven + 1);
BOOST_CHECK_EQUAL(lexical_cast<std::string>(crng2), "1");
BOOST_CHECK_EQUAL(lexical_cast<float>(rng1), 1.0f);
BOOST_CHECK_EQUAL(lexical_cast<double>(rng1), 1.0);
BOOST_CHECK_EQUAL(lexical_cast<long double>(rng1), 1.0L);
BOOST_CHECK_EQUAL(lexical_cast<class_with_user_defined_sream_operators>(rng1), 1);
BOOST_CHECK_EQUAL(lexical_cast<float>(crng2), 1.0f);
BOOST_CHECK_EQUAL(lexical_cast<double>(crng2), 1.0);
BOOST_CHECK_EQUAL(lexical_cast<long double>(crng2), 1.0L);
BOOST_CHECK_EQUAL(lexical_cast<class_with_user_defined_sream_operators>(crng2), 1);
#ifndef BOOST_LCAST_NO_WCHAR_T
BOOST_CHECK(lexical_cast<std::wstring>(rng1) == L"1");
BOOST_CHECK(lexical_cast<std::wstring>(crng1) == L"1");
BOOST_CHECK(lexical_cast<std::wstring>(rng2) == L"1");
BOOST_CHECK(lexical_cast<std::wstring>(crng2) == L"1");
#endif
#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS) && defined(BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES)
typedef std::basic_string<char16_t> my_char16_string;
BOOST_CHECK(lexical_cast<my_char16_string>(rng1) == u"1");
BOOST_CHECK(lexical_cast<my_char16_string>(crng1) == u"1");
BOOST_CHECK(lexical_cast<my_char16_string>(rng2) == u"1");
BOOST_CHECK(lexical_cast<my_char16_string>(crng2) == u"1");
#endif
#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS) && defined(BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES)
typedef std::basic_string<char32_t> my_char32_string;
BOOST_CHECK(lexical_cast<my_char32_string>(rng1) == U"1");
BOOST_CHECK(lexical_cast<my_char32_string>(crng1) == U"1");
BOOST_CHECK(lexical_cast<my_char32_string>(rng2) == U"1");
BOOST_CHECK(lexical_cast<my_char32_string>(crng2) == U"1");
#endif
}
void test_char_iterator_ranges()
{
typedef char test_char_type;
test_char_type data1[] = "1";
test_char_type data2[] = "11";
test_it_range_using_any_chars(data1, data2);
test_it_range_using_char(data1, data2);
}
void test_unsigned_char_iterator_ranges()
{
typedef unsigned char test_char_type;
test_char_type data1[] = "1";
test_char_type data2[] = "11";
test_it_range_using_any_chars(data1, data2);
test_it_range_using_char(data1, data2);
}
void test_signed_char_iterator_ranges()
{
typedef signed char test_char_type;
test_char_type data1[] = "1";
test_char_type data2[] = "11";
test_it_range_using_any_chars(data1, data2);
test_it_range_using_char(data1, data2);
}
void test_wchar_iterator_ranges()
{
#ifndef BOOST_LCAST_NO_WCHAR_T
typedef wchar_t test_char_type;
test_char_type data1[] = L"1";
test_char_type data2[] = L"11";
test_it_range_using_any_chars(data1, data2);
#endif
BOOST_CHECK(true);
}
void test_char16_iterator_ranges()
{
#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS)
typedef char16_t test_char_type;
test_char_type data1[] = u"1";
test_char_type data2[] = u"11";
test_it_range_using_any_chars(data1, data2);
#endif
BOOST_CHECK(true);
}
void test_char32_iterator_ranges()
{
#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS)
typedef char32_t test_char_type;
test_char_type data1[] = U"1";
test_char_type data2[] = U"11";
test_it_range_using_any_chars(data1, data2);
#endif
BOOST_CHECK(true);
}
unit_test::test_suite *init_unit_test_suite(int, char *[])
{
unit_test::test_suite *suite = BOOST_TEST_SUITE("lexical_cast. Testing conversions using iterator_range<>");
suite->add(BOOST_TEST_CASE(&test_char_iterator_ranges));
suite->add(BOOST_TEST_CASE(&test_unsigned_char_iterator_ranges));
suite->add(BOOST_TEST_CASE(&test_signed_char_iterator_ranges));
suite->add(BOOST_TEST_CASE(&test_wchar_iterator_ranges));
suite->add(BOOST_TEST_CASE(&test_char16_iterator_ranges));
suite->add(BOOST_TEST_CASE(&test_char32_iterator_ranges));
return suite;
}
+1 -1
View File
@@ -30,7 +30,7 @@ void test_round_conversion_long_double();
unit_test::test_suite *init_unit_test_suite(int, char *[])
{
unit_test_framework::test_suite *suite =
unit_test::test_suite *suite =
BOOST_TEST_SUITE("lexical_cast unit test");
suite->add(BOOST_TEST_CASE(&test_round_conversion_float));
suite->add(BOOST_TEST_CASE(&test_round_conversion_double));
+95
View File
@@ -0,0 +1,95 @@
// Unit test for boost::lexical_cast.
//
// See http://www.boost.org for most recent version, including documentation.
//
// Copyright Antony Polukhin, 2012.
//
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
#include <boost/config.hpp>
#if defined(__INTEL_COMPILER)
#pragma warning(disable: 193 383 488 981 1418 1419)
#elif defined(BOOST_MSVC)
#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800)
#endif
#include <boost/lexical_cast.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/range/iterator_range.hpp>
#ifndef BOOST_NO_EXCEPTIONS
#error "This test must be compiled with -DBOOST_NO_EXCEPTIONS"
#endif
bool g_was_exception = false;
namespace boost {
void throw_exception(std::exception const & ) {
g_was_exception = true;
}
}
using namespace boost;
struct Escape
{
Escape(){}
Escape(const std::string& s)
: str_(s)
{}
std::string str_;
};
inline std::ostream& operator<< (std::ostream& o, const Escape& rhs)
{
return o << rhs.str_;
}
inline std::istream& operator>> (std::istream& i, Escape& rhs)
{
return i >> rhs.str_;
}
void test_exceptions_off()
{
Escape v("");
g_was_exception = false;
lexical_cast<char>(v);
BOOST_CHECK(g_was_exception);
g_was_exception = false;
lexical_cast<unsigned char>(v);
BOOST_CHECK(g_was_exception);
v = lexical_cast<Escape>(100);
BOOST_CHECK_EQUAL(lexical_cast<int>(v), 100);
BOOST_CHECK_EQUAL(lexical_cast<unsigned int>(v), 100u);
v = lexical_cast<Escape>(0.0);
BOOST_CHECK_EQUAL(lexical_cast<double>(v), 0.0);
BOOST_CHECK_EQUAL(lexical_cast<short>(100), 100);
BOOST_CHECK_EQUAL(lexical_cast<float>(0.0), 0.0);
g_was_exception = false;
lexical_cast<short>(700000);
BOOST_CHECK(g_was_exception);
}
unit_test::test_suite *init_unit_test_suite(int, char *[])
{
unit_test::test_suite *suite =
BOOST_TEST_SUITE("lexical_cast. Testing with BOOST_NO_EXCEPTIONS");
suite->add(BOOST_TEST_CASE(&test_exceptions_off));
return suite;
}
+166
View File
@@ -0,0 +1,166 @@
// Unit test for boost::lexical_cast.
//
// See http://www.boost.org for most recent version, including documentation.
//
// Copyright Antony Polukhin, 2012.
//
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
#include <boost/config.hpp>
#if defined(__INTEL_COMPILER)
#pragma warning(disable: 193 383 488 981 1418 1419)
#elif defined(BOOST_MSVC)
#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800)
#endif
#include <boost/lexical_cast.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/range/iterator_range.hpp>
using namespace boost;
// Testing compilation and some basic usage with BOOST_NO_STD_LOCALE
// Tests are mainly copyied from lexical_cast_empty_input_test.cpp (something
// new added to test_empty_3)
#ifndef BOOST_NO_STD_LOCALE
#error "This test must be compiled with -DBOOST_NO_STD_LOCALE"
#endif
template <class T>
void do_test_on_empty_input(T& v)
{
BOOST_CHECK_THROW(lexical_cast<int>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<float>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<double>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<long double>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<unsigned int>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<unsigned short>(v), bad_lexical_cast);
#if defined(BOOST_HAS_LONG_LONG)
BOOST_CHECK_THROW(lexical_cast<boost::ulong_long_type>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<boost::long_long_type>(v), bad_lexical_cast);
#elif defined(BOOST_HAS_MS_INT64)
BOOST_CHECK_THROW(lexical_cast<unsigned __int64>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<__int64>(v), bad_lexical_cast);
#endif
}
void test_empty_1()
{
boost::iterator_range<char*> v;
do_test_on_empty_input(v);
BOOST_CHECK_EQUAL(lexical_cast<std::string>(v), std::string());
BOOST_CHECK_THROW(lexical_cast<char>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<unsigned char>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<signed char>(v), bad_lexical_cast);
boost::iterator_range<const char*> cv;
do_test_on_empty_input(cv);
BOOST_CHECK_EQUAL(lexical_cast<std::string>(cv), std::string());
BOOST_CHECK_THROW(lexical_cast<char>(cv), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<unsigned char>(cv), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<signed char>(cv), bad_lexical_cast);
const boost::iterator_range<const char*> ccv;
do_test_on_empty_input(ccv);
BOOST_CHECK_EQUAL(lexical_cast<std::string>(ccv), std::string());
BOOST_CHECK_THROW(lexical_cast<char>(ccv), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<unsigned char>(ccv), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<signed char>(ccv), bad_lexical_cast);
}
void test_empty_2()
{
std::string v;
do_test_on_empty_input(v);
BOOST_CHECK_THROW(lexical_cast<char>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<unsigned char>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<signed char>(v), bad_lexical_cast);
}
struct Escape
{
Escape(){}
Escape(const std::string& s)
: str_(s)
{}
std::string str_;
};
inline std::ostream& operator<< (std::ostream& o, const Escape& rhs)
{
return o << rhs.str_;
}
inline std::istream& operator>> (std::istream& i, Escape& rhs)
{
return i >> rhs.str_;
}
void test_empty_3()
{
Escape v("");
do_test_on_empty_input(v);
BOOST_CHECK_THROW(lexical_cast<char>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<unsigned char>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<signed char>(v), bad_lexical_cast);
v = lexical_cast<Escape>(100);
BOOST_CHECK_EQUAL(lexical_cast<int>(v), 100);
BOOST_CHECK_EQUAL(lexical_cast<unsigned int>(v), 100u);
v = lexical_cast<Escape>(0.0);
BOOST_CHECK_EQUAL(lexical_cast<double>(v), 0.0);
}
namespace std {
inline std::ostream & operator<<(std::ostream & out, const std::vector<long> & v)
{
std::ostream_iterator<long> it(out);
std::copy(v.begin(), v.end(), it);
assert(out);
return out;
}
}
void test_empty_4()
{
std::vector<long> v;
do_test_on_empty_input(v);
BOOST_CHECK_THROW(lexical_cast<char>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<unsigned char>(v), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<signed char>(v), bad_lexical_cast);
}
struct my_string {
friend std::ostream &operator<<(std::ostream& sout, my_string const&/* st*/) {
return sout << "";
}
};
void test_empty_5()
{
my_string st;
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(st), std::string());;
}
unit_test::test_suite *init_unit_test_suite(int, char *[])
{
unit_test::test_suite *suite =
BOOST_TEST_SUITE("lexical_cast. Testing with BOOST_NO_STD_LOCALE");
suite->add(BOOST_TEST_CASE(&test_empty_1));
suite->add(BOOST_TEST_CASE(&test_empty_2));
suite->add(BOOST_TEST_CASE(&test_empty_3));
suite->add(BOOST_TEST_CASE(&test_empty_4));
suite->add(BOOST_TEST_CASE(&test_empty_5));
return suite;
}
+1 -1
View File
@@ -28,7 +28,7 @@ void test_noncopyable();
unit_test::test_suite *init_unit_test_suite(int, char *[])
{
unit_test_framework::test_suite *suite =
unit_test::test_suite *suite =
BOOST_TEST_SUITE("lexical_cast unit test");
suite->add(BOOST_TEST_CASE(&test_noncopyable));
+96
View File
@@ -0,0 +1,96 @@
// Unit test for boost::lexical_cast.
//
// See http://www.boost.org for most recent version, including documentation.
//
// Copyright Antony Polukhin, 2012.
//
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
#include <boost/config.hpp>
#if defined(__INTEL_COMPILER)
#pragma warning(disable: 193 383 488 981 1418 1419)
#elif defined(BOOST_MSVC)
#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800)
#endif
#include <boost/lexical_cast.hpp>
#include <boost/test/unit_test.hpp>
using namespace boost;
#if defined(BOOST_NO_STRINGSTREAM)
typedef std::strstream ss_t;
#else
typedef std::stringstream ss_t;
#endif
void test_void_pointers_conversions()
{
void *p_to_null = NULL;
const void *cp_to_data = "Some data";
char nonconst_data[5];
void *p_to_data = nonconst_data;
ss_t ss;
ss << p_to_null;
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(p_to_null), ss.str());
ss.str(std::string());
ss << cp_to_data;
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(cp_to_data), ss.str());
ss.str(std::string());
ss << p_to_data;
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(p_to_data), ss.str());
ss.str(std::string());
}
struct incomplete_type;
void test_incomplete_type_pointers_conversions()
{
incomplete_type *p_to_null = NULL;
const incomplete_type *cp_to_data = NULL;
char nonconst_data[5];
incomplete_type *p_to_data = reinterpret_cast<incomplete_type*>(nonconst_data);
ss_t ss;
ss << p_to_null;
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(p_to_null), ss.str());
ss.str(std::string());
ss << cp_to_data;
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(cp_to_data), ss.str());
ss.str(std::string());
ss << p_to_data;
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(p_to_data), ss.str());
ss.str(std::string());
}
struct ble;
typedef struct ble *meh;
std::ostream& operator <<(std::ostream &o, meh) {
o << "yay";
return o;
}
void test_inomplete_type_with_overloaded_ostream_op() {
meh heh = NULL;
ss_t ss;
ss << heh;
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(heh), ss.str());
}
unit_test::test_suite *init_unit_test_suite(int, char *[])
{
unit_test::test_suite *suite =
BOOST_TEST_SUITE("lexical_cast pinters test");
suite->add(BOOST_TEST_CASE(&test_void_pointers_conversions));
suite->add(BOOST_TEST_CASE(&test_incomplete_type_pointers_conversions));
suite->add(BOOST_TEST_CASE(&test_inomplete_type_with_overloaded_ostream_op));
return suite;
}
+40
View File
@@ -0,0 +1,40 @@
// Unit test for boost::lexical_cast.
//
// See http://www.boost.org for most recent version, including documentation.
//
// Copyright Antony Polukhin, 2011.
//
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
#include <boost/config.hpp>
#include <boost/static_assert.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
void parseDate()
{
std::locale locale;
boost::date_time::format_date_parser<boost::gregorian::date, wchar_t> parser(L"", locale);
boost::date_time::special_values_parser<boost::gregorian::date, wchar_t> svp;
boost::gregorian::date date = parser.parse_date(L"", L"", svp);
(void)date;
}
int main()
{
#ifdef BOOST_MSVC
BOOST_STATIC_ASSERT((boost::is_same<wchar_t, unsigned short>::value));
#endif
parseDate();
return ::boost::lexical_cast<int>(L"1000") == 1000;
}
+48
View File
@@ -0,0 +1,48 @@
// Unit test for boost::lexical_cast.
//
// See http://www.boost.org for most recent version, including documentation.
//
// Copyright Antony Polukhin, 2011.
//
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
#include <boost/config.hpp>
#if defined(__INTEL_COMPILER)
#pragma warning(disable: 193 383 488 981 1418 1419)
#elif defined(BOOST_MSVC)
#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800)
#endif
#include <boost/lexical_cast.hpp>
#include <boost/test/unit_test.hpp>
using namespace boost;
void test_typedefed_wchar_t_runtime()
{
#ifndef BOOST_LCAST_NO_WCHAR_T
#ifdef BOOST_MSVC
BOOST_STATIC_ASSERT((boost::is_same<wchar_t, unsigned short>::value));
BOOST_CHECK_EQUAL(boost::lexical_cast<int>(L'A'), 65);
BOOST_CHECK_EQUAL(boost::lexical_cast<int>(L'B'), 66);
BOOST_CHECK_EQUAL(boost::lexical_cast<wchar_t>(L"65"), 65);
BOOST_CHECK_EQUAL(boost::lexical_cast<wchar_t>(L"66"), 66);
#endif
#endif
BOOST_CHECK(1);
}
unit_test::test_suite *init_unit_test_suite(int, char *[])
{
unit_test::test_suite *suite =
BOOST_TEST_SUITE("lexical_cast typedefed wchar_t runtime test");
suite->add(BOOST_TEST_CASE(&test_typedefed_wchar_t_runtime));
return suite;
}
+1 -1
View File
@@ -60,7 +60,7 @@ void test_vc8_bug()
unit_test::test_suite *init_unit_test_suite(int, char *[])
{
unit_test_framework::test_suite *suite =
unit_test::test_suite *suite =
BOOST_TEST_SUITE("lexical_cast vc8 bug unit test");
suite->add(BOOST_TEST_CASE(test_vc8_bug));
return suite;
+47 -17
View File
@@ -2,7 +2,7 @@
//
// See http://www.boost.org for most recent version, including documentation.
//
// Copyright Antony Polukhin, 2011.
// Copyright Antony Polukhin, 2011-2012.
//
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
@@ -17,40 +17,70 @@
#endif
#include <boost/lexical_cast.hpp>
#include <boost/cstdint.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/test/floating_point_comparison.hpp>
using namespace boost;
void test_char_types_conversions()
#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING)
#define BOOST_LCAST_NO_WCHAR_T
#endif
template <class CharT>
void test_impl(const CharT* wc_arr)
{
#ifndef BOOST_LCAST_NO_WCHAR_T
typedef CharT wide_char;
typedef std::basic_string<CharT> wide_string;
const char c_arr[] = "Test array of chars";
const unsigned char uc_arr[] = "Test array of chars";
const signed char sc_arr[] = "Test array of chars";
const wchar_t wc_arr[] =L"Test array of chars";
// Following tests depend on realization of std::locale
// and pass for popular compilers and STL realizations
BOOST_CHECK(boost::lexical_cast<wchar_t>(c_arr[0]) == wc_arr[0]);
BOOST_CHECK(boost::lexical_cast<std::wstring>(c_arr) == std::wstring(wc_arr));
BOOST_CHECK(boost::lexical_cast<wide_char>(c_arr[0]) == wc_arr[0]);
BOOST_CHECK(boost::lexical_cast<wide_string>(c_arr) == wide_string(wc_arr));
BOOST_CHECK(boost::lexical_cast<std::wstring>(sc_arr) == std::wstring(wc_arr) );
BOOST_CHECK(boost::lexical_cast<std::wstring>(uc_arr) == std::wstring(wc_arr) );
BOOST_CHECK(boost::lexical_cast<wide_string>(sc_arr) == wide_string(wc_arr) );
BOOST_CHECK(boost::lexical_cast<wide_string>(uc_arr) == wide_string(wc_arr) );
BOOST_CHECK_EQUAL(boost::lexical_cast<wchar_t>(uc_arr[0]), wc_arr[0]);
BOOST_CHECK_EQUAL(boost::lexical_cast<wchar_t>(sc_arr[0]), wc_arr[0]);
BOOST_CHECK_EQUAL(boost::lexical_cast<wide_char>(uc_arr[0]), wc_arr[0]);
BOOST_CHECK_EQUAL(boost::lexical_cast<wide_char>(sc_arr[0]), wc_arr[0]);
}
void test_char_types_conversions_wchar_t()
{
#ifndef BOOST_LCAST_NO_WCHAR_T
test_impl(L"Test array of chars");
#endif
BOOST_CHECK(1);
BOOST_CHECK(true);
}
void test_char_types_conversions_char16_t()
{
#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS) && defined(BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES)
test_impl(u"Test array of chars");
#endif
BOOST_CHECK(true);
}
void test_char_types_conversions_char32_t()
{
#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS) && defined(BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES)
test_impl(U"Test array of chars");
#endif
BOOST_CHECK(true);
}
unit_test::test_suite *init_unit_test_suite(int, char *[])
{
unit_test_framework::test_suite *suite =
BOOST_TEST_SUITE("lexical_cast char<->wchar_t unit test");
suite->add(BOOST_TEST_CASE(&test_char_types_conversions));
unit_test::test_suite *suite =
BOOST_TEST_SUITE("lexical_cast char => wide characters unit test (widening test)");
suite->add(BOOST_TEST_CASE(&test_char_types_conversions_wchar_t));
suite->add(BOOST_TEST_CASE(&test_char_types_conversions_char16_t));
suite->add(BOOST_TEST_CASE(&test_char_types_conversions_char32_t));
return suite;
}