Compare commits

..

1 Commits

Author SHA1 Message Date
Beman Dawes 3271717a5d Release 1.50.0
[SVN r79156]
2012-06-28 12:37:29 +00:00
12 changed files with 997 additions and 1889 deletions
+411 -538
View File
@@ -70,22 +70,6 @@ The following example uses numeric data in a string expression:
log_message("Error " + boost::lexical_cast<std::string>(yoko) + ": " + strerror(yoko));
}
``
Following example converts some number and puts it to file:
``
int i;
FILE* file;
...
typedef boost::array<char, 50> buf_t; // You can use std::array if your compiler supports it
buf_t buffer = boost::lexical_cast<buf_t>(i); // No dynamic memory allocation
puts(buffer.begin(), file);
``
Following example takes part of the string and converts it to `int`:
``
int convert_strings_part(const std::string& s, std::size_t pos, std::size_t n)
{
return boost::lexical_cast<int>(s.data() + pos, n);
}
``
[endsect]
[section Synopsis]
@@ -106,13 +90,7 @@ Library features defined in [@boost:boost/lexical_cast.hpp boost/lexical_cast.hp
``
Returns the result of streaming arg into a standard library string-based stream and then out as a Target object. Where Target is either `std::string` or `std::wstring`, stream extraction takes the whole content of the string, including spaces, rather than relying on the default `operator>>` behavior. If the conversion is unsuccessful, a `bad_lexical_cast` exception is thrown.
``
template <typename Target>
Target lexical_cast(const AnyCharacterType* chars, std::size_t count);
``
Takes an array of `count` characters as input parameter and streams them out as a Target object. If the conversion is unsuccessful, a `bad_lexical_cast` exception is thrown. This call may be useful for processing nonzero terminated array of characters or processing just some part of character array.
The requirements on the argument and result types for both functions are:
The requirements on the argument and result types are:
* Source is OutputStreamable, meaning that an `operator<<` is defined that takes a `std::ostream` or `std::wostream` object on the left hand side and an instance of the argument type on the right.
* Target is InputStreamable, meaning that an `operator>>` is defined that takes a `std::istream` or `std::wistream` object on the left hand side and an instance of the result type on the right.
@@ -125,15 +103,13 @@ The character type of the underlying stream is assumed to be `char` unless eithe
* 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
* `boost::array<CharT, N>` and `std::array<CharT, N>`, `boost::array<const CharT, N>` and `std::array<const CharT, N>`
[important Many compilers and runtime libraries fail to make conversions using new Unicode characters. Make sure that the following code compiles and outputs nonzero values, before using new types:
[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
<< boost::lexical_cast<std::u32string>(1.0).size()
<< booat::lexical_cast<std::u32string>(1.0).size()
<< " "
<< boost::lexical_cast<std::u16string>(1.0).size();
<< booat::lexical_cast<std::u16string>(1.0).size();
``
]
@@ -263,25 +239,12 @@ limitation of compiler options that you use.
, `"-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.
[pre
]
* [*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 or `lexical_cast` overload with two parameters. For example, if you whant to convert to `int` two characters from a string `str`, you shall write `lexical_cast<int>(make_iterator_range(str.data(), str.data() + 2));` or `lexical_cast<int>(str.data(), 2);`.
* [*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.52.0 :]
* Restored compilation on MSVC-2003 (was broken in 1.51.0).
* Added `lexical_cast(const CharType* chars, std::size_t count)` function overload.
* [*boost 1.51.0 :]
* Better performance, less memory usage for `boost::array<character_type, N>` and `std::array<character_type, N>` conversions.
* [*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.
@@ -372,507 +335,417 @@ Do not use this results to compare compilers, because tests were taken on differ
[/ BEGIN of section, generated by performance measuring program ]
[section Clang version 3.0 (tags/RELEASE_30/final)]
[table:id Performance Table ( Clang version 3.0 (tags/RELEASE_30/final))
[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* !!! ][ 169 ][ 9 ][ 10 ]]
[[ string->signed char ][ !!! *<1* !!! ][ 108 ][ 8 ][ 10 ]]
[[ string->unsigned char ][ !!! *<1* !!! ][ 103 ][ 9 ][ 10 ]]
[[ string->int ][ !!! *6* !!! ][ 117 ][ 24 ][ 24 ]]
[[ string->short ][ !!! *7* !!! ][ 115 ][ 20 ][ 24 ]]
[[ string->long int ][ !!! *7* !!! ][ 115 ][ 19 ][ 22 ]]
[[ string->long long ][ !!! *8* !!! ][ 116 ][ 21 ][ 23 ]]
[[ string->unsigned int ][ !!! *6* !!! ][ 121 ][ 18 ][ 23 ]]
[[ string->unsigned short ][ !!! *6* !!! ][ 116 ][ 19 ][ 22 ]]
[[ string->unsigned long int ][ !!! *7* !!! ][ 117 ][ 23 ][ 21 ]]
[[ string->unsigned long long ][ !!! *8* !!! ][ 118 ][ 19 ][ 34 ]]
[[ string->float ][ !!! *13* !!! ][ 201 ][ 55 ][ 41 ]]
[[ string->double ][ !!! *14* !!! ][ 151 ][ 54 ][ 41 ]]
[[ string->long double ][ 195 ][ 231 ][ 67 ][ !!! *42* !!! ]]
[[ string->array<char, 50> ][ !!! *<1* !!! ][ 121 ][ 18 ][ 12 ]]
[[ string->string ][ !!! *1* !!! ][ 124 ][ 27 ][ --- ]]
[[ string->container::string ][ !!! *3* !!! ][ 114 ][ 25 ][ --- ]]
[[ string->char ][ 7 ][ 111 ][ 25 ][ !!! *7* !!! ]]
[[ string->signed char ][ !!! *6* !!! ][ 112 ][ 30 ][ 26 ]]
[[ string->unsigned char ][ !!! *6* !!! ][ 113 ][ 25 ][ 24 ]]
[[ int->string ][ !!! *12* !!! ][ 126 ][ 36 ][ 21 ]]
[[ short->string ][ !!! *11* !!! ][ 135 ][ 30 ][ 21 ]]
[[ long int->string ][ !!! *11* !!! ][ 128 ][ 28 ][ 21 ]]
[[ long long->string ][ !!! *12* !!! ][ 126 ][ 32 ][ 24 ]]
[[ unsigned int->string ][ !!! *11* !!! ][ 131 ][ 36 ][ 22 ]]
[[ unsigned short->string ][ !!! *11* !!! ][ 130 ][ 28 ][ 22 ]]
[[ unsigned long int->string ][ !!! *11* !!! ][ 130 ][ 36 ][ 22 ]]
[[ unsigned long long->string ][ !!! *11* !!! ][ 127 ][ 43 ][ 25 ]]
[[ float->string ][ 53 ][ 190 ][ 83 ][ !!! *41* !!! ]]
[[ double->string ][ 59 ][ 197 ][ 82 ][ !!! *44* !!! ]]
[[ long double->string ][ 118 ][ 229 ][ 101 ][ !!! *44* !!! ]]
[[ char*->char ][ !!! *1* !!! ][ 105 ][ 9 ][ 9 ]]
[[ char*->signed char ][ !!! *1* !!! ][ 107 ][ 10 ][ 10 ]]
[[ char*->unsigned char ][ !!! *1* !!! ][ 106 ][ 9 ][ 11 ]]
[[ char*->int ][ !!! *7* !!! ][ 149 ][ 25 ][ 24 ]]
[[ char*->short ][ !!! *7* !!! ][ 118 ][ 20 ][ 22 ]]
[[ char*->long int ][ !!! *9* !!! ][ 117 ][ 20 ][ 28 ]]
[[ char*->long long ][ !!! *9* !!! ][ 128 ][ 23 ][ 29 ]]
[[ char*->unsigned int ][ !!! *7* !!! ][ 120 ][ 19 ][ 23 ]]
[[ char*->unsigned short ][ !!! *7* !!! ][ 125 ][ 20 ][ 22 ]]
[[ char*->unsigned long int ][ !!! *8* !!! ][ 125 ][ 21 ][ 24 ]]
[[ char*->unsigned long long ][ !!! *8* !!! ][ 130 ][ 19 ][ 22 ]]
[[ char*->float ][ !!! *14* !!! ][ 162 ][ 56 ][ 41 ]]
[[ char*->double ][ !!! *16* !!! ][ 151 ][ 54 ][ 39 ]]
[[ char*->long double ][ 111 ][ 176 ][ 58 ][ !!! *42* !!! ]]
[[ char*->array<char, 50> ][ !!! *1* !!! ][ 116 ][ 20 ][ 17 ]]
[[ char*->string ][ !!! *8* !!! ][ 125 ][ 27 ][ --- ]]
[[ char*->container::string ][ !!! *2* !!! ][ 115 ][ 26 ][ --- ]]
[[ unsigned char*->char ][ !!! *1* !!! ][ 101 ][ 9 ][ 9 ]]
[[ unsigned char*->signed char ][ !!! *1* !!! ][ 104 ][ 9 ][ 11 ]]
[[ unsigned char*->unsigned char ][ !!! *1* !!! ][ 103 ][ 9 ][ 13 ]]
[[ unsigned char*->int ][ !!! *8* !!! ][ 116 ][ 20 ][ 24 ]]
[[ unsigned char*->short ][ !!! *7* !!! ][ 121 ][ 20 ][ 26 ]]
[[ unsigned char*->long int ][ !!! *8* !!! ][ 118 ][ 20 ][ 22 ]]
[[ unsigned char*->long long ][ !!! *8* !!! ][ 122 ][ 20 ][ 23 ]]
[[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 119 ][ 22 ][ 23 ]]
[[ unsigned char*->unsigned short ][ !!! *7* !!! ][ 122 ][ 20 ][ 22 ]]
[[ unsigned char*->unsigned long int ][ !!! *8* !!! ][ 125 ][ 21 ][ 22 ]]
[[ unsigned char*->unsigned long long ][ !!! *8* !!! ][ 122 ][ 19 ][ 25 ]]
[[ unsigned char*->float ][ !!! *14* !!! ][ 162 ][ 62 ][ 37 ]]
[[ unsigned char*->double ][ !!! *15* !!! ][ 151 ][ 58 ][ 39 ]]
[[ unsigned char*->long double ][ 116 ][ 156 ][ 58 ][ !!! *42* !!! ]]
[[ unsigned char*->array<char, 50> ][ !!! *1* !!! ][ 122 ][ 19 ][ 15 ]]
[[ unsigned char*->string ][ !!! *8* !!! ][ 124 ][ 27 ][ --- ]]
[[ unsigned char*->container::string ][ !!! *4* !!! ][ 119 ][ 25 ][ --- ]]
[[ signed char*->char ][ !!! *1* !!! ][ 107 ][ 9 ][ 9 ]]
[[ signed char*->signed char ][ !!! *1* !!! ][ 108 ][ 10 ][ 11 ]]
[[ signed char*->unsigned char ][ !!! *1* !!! ][ 106 ][ 9 ][ 11 ]]
[[ signed char*->int ][ !!! *7* !!! ][ 122 ][ 21 ][ 22 ]]
[[ signed char*->short ][ !!! *7* !!! ][ 126 ][ 20 ][ 22 ]]
[[ signed char*->long int ][ !!! *8* !!! ][ 119 ][ 20 ][ 23 ]]
[[ signed char*->long long ][ !!! *8* !!! ][ 119 ][ 21 ][ 26 ]]
[[ signed char*->unsigned int ][ !!! *6* !!! ][ 124 ][ 18 ][ 22 ]]
[[ signed char*->unsigned short ][ !!! *7* !!! ][ 124 ][ 21 ][ 23 ]]
[[ signed char*->unsigned long int ][ !!! *8* !!! ][ 121 ][ 24 ][ 23 ]]
[[ signed char*->unsigned long long ][ !!! *8* !!! ][ 122 ][ 20 ][ 22 ]]
[[ signed char*->float ][ !!! *14* !!! ][ 167 ][ 56 ][ 37 ]]
[[ signed char*->double ][ !!! *14* !!! ][ 162 ][ 53 ][ 40 ]]
[[ signed char*->long double ][ 110 ][ 152 ][ 56 ][ !!! *42* !!! ]]
[[ signed char*->array<char, 50> ][ !!! *1* !!! ][ 117 ][ 19 ][ 12 ]]
[[ signed char*->string ][ !!! *8* !!! ][ 132 ][ 27 ][ --- ]]
[[ signed char*->container::string ][ !!! *4* !!! ][ 116 ][ 26 ][ --- ]]
[[ iterator_range<char*>->char ][ !!! *<1* !!! ][ 112 ][ 14 ][ 9 ]]
[[ iterator_range<char*>->signed char ][ !!! *<1* !!! ][ 107 ][ 13 ][ 10 ]]
[[ iterator_range<char*>->unsigned char ][ !!! *<1* !!! ][ 145 ][ 15 ][ 10 ]]
[[ iterator_range<char*>->int ][ !!! *6* !!! ][ 119 ][ 22 ][ 23 ]]
[[ iterator_range<char*>->short ][ !!! *6* !!! ][ 115 ][ 22 ][ 23 ]]
[[ iterator_range<char*>->long int ][ !!! *7* !!! ][ 115 ][ 25 ][ 22 ]]
[[ iterator_range<char*>->long long ][ !!! *7* !!! ][ 117 ][ 21 ][ 23 ]]
[[ iterator_range<char*>->unsigned int ][ !!! *6* !!! ][ 118 ][ 22 ][ 22 ]]
[[ iterator_range<char*>->unsigned short ][ !!! *6* !!! ][ 117 ][ 24 ][ 22 ]]
[[ iterator_range<char*>->unsigned long int ][ !!! *7* !!! ][ 124 ][ 25 ][ 22 ]]
[[ iterator_range<char*>->unsigned long long ][ !!! *7* !!! ][ 119 ][ 22 ][ 22 ]]
[[ iterator_range<char*>->float ][ !!! *13* !!! ][ 159 ][ 42 ][ 41 ]]
[[ iterator_range<char*>->double ][ !!! *14* !!! ][ 152 ][ 40 ][ 40 ]]
[[ iterator_range<char*>->long double ][ 113 ][ 155 ][ 58 ][ !!! *54* !!! ]]
[[ iterator_range<char*>->array<char, 50> ][ !!! *<1* !!! ][ 127 ][ 23 ][ 13 ]]
[[ iterator_range<char*>->string ][ !!! *7* !!! ][ 132 ][ 30 ][ --- ]]
[[ iterator_range<char*>->container::string ][ !!! *3* !!! ][ 122 ][ 24 ][ --- ]]
[[ array<char, 50>->char ][ !!! *<1* !!! ][ 110 ][ 9 ][ 10 ]]
[[ array<char, 50>->signed char ][ !!! *<1* !!! ][ 119 ][ 9 ][ 13 ]]
[[ array<char, 50>->unsigned char ][ !!! *<1* !!! ][ 106 ][ 13 ][ 11 ]]
[[ array<char, 50>->int ][ !!! *6* !!! ][ 131 ][ 21 ][ 22 ]]
[[ array<char, 50>->short ][ !!! *7* !!! ][ 119 ][ 22 ][ 28 ]]
[[ array<char, 50>->long int ][ !!! *8* !!! ][ 133 ][ 21 ][ 26 ]]
[[ array<char, 50>->long long ][ !!! *8* !!! ][ 115 ][ 22 ][ 23 ]]
[[ array<char, 50>->unsigned int ][ !!! *6* !!! ][ 118 ][ 18 ][ 22 ]]
[[ array<char, 50>->unsigned short ][ !!! *7* !!! ][ 119 ][ 19 ][ 22 ]]
[[ array<char, 50>->unsigned long int ][ !!! *7* !!! ][ 118 ][ 23 ][ 21 ]]
[[ array<char, 50>->unsigned long long ][ !!! *7* !!! ][ 117 ][ 20 ][ 22 ]]
[[ array<char, 50>->float ][ !!! *15* !!! ][ 156 ][ 53 ][ 36 ]]
[[ array<char, 50>->double ][ !!! *15* !!! ][ 148 ][ 55 ][ 39 ]]
[[ array<char, 50>->long double ][ 110 ][ 150 ][ 56 ][ !!! *41* !!! ]]
[[ array<char, 50>->array<char, 50> ][ !!! *<1* !!! ][ 117 ][ 19 ][ 12 ]]
[[ array<char, 50>->string ][ !!! *7* !!! ][ 124 ][ 26 ][ --- ]]
[[ array<char, 50>->container::string ][ !!! *4* !!! ][ 115 ][ 26 ][ --- ]]
[[ int->int ][ !!! *<1* !!! ][ 117 ][ 24 ][ --- ]]
[[ float->double ][ !!! *<1* !!! ][ 245 ][ 125 ][ --- ]]
[[ char->signed char ][ !!! *<1* !!! ][ 100 ][ 9 ][ --- ]]
]
[endsect]
[section GNU C++ version 4.6.3]
[table:id Performance Table ( GNU C++ version 4.6.3)
[[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]]
[[ string->char ][ !!! *<1* !!! ][ 142 ][ 10 ][ 18 ]]
[[ string->signed char ][ !!! *<1* !!! ][ 111 ][ 8 ][ 10 ]]
[[ string->unsigned char ][ !!! *<1* !!! ][ 101 ][ 8 ][ 10 ]]
[[ string->int ][ !!! *7* !!! ][ 110 ][ 20 ][ 24 ]]
[[ string->short ][ !!! *6* !!! ][ 109 ][ 20 ][ 25 ]]
[[ string->long int ][ !!! *7* !!! ][ 113 ][ 19 ][ 24 ]]
[[ string->long long ][ !!! *7* !!! ][ 116 ][ 24 ][ 23 ]]
[[ string->unsigned int ][ !!! *6* !!! ][ 110 ][ 19 ][ 23 ]]
[[ string->unsigned short ][ !!! *5* !!! ][ 116 ][ 18 ][ 23 ]]
[[ string->unsigned long int ][ !!! *7* !!! ][ 111 ][ 22 ][ 23 ]]
[[ string->unsigned long long ][ !!! *7* !!! ][ 108 ][ 20 ][ 22 ]]
[[ string->float ][ !!! *11* !!! ][ 161 ][ 54 ][ 38 ]]
[[ string->double ][ !!! *11* !!! ][ 146 ][ 56 ][ 41 ]]
[[ string->long double ][ 113 ][ 151 ][ 59 ][ !!! *43* !!! ]]
[[ string->array<char, 50> ][ !!! *<1* !!! ][ 107 ][ 18 ][ 14 ]]
[[ string->string ][ !!! *2* !!! ][ 127 ][ 24 ][ --- ]]
[[ string->container::string ][ !!! *3* !!! ][ 142 ][ 26 ][ --- ]]
[[ string->char ][ !!! *7* !!! ][ 110 ][ 23 ][ 17 ]]
[[ string->signed char ][ !!! *7* !!! ][ 114 ][ 23 ][ 24 ]]
[[ string->unsigned char ][ !!! *7* !!! ][ 110 ][ 25 ][ 24 ]]
[[ int->string ][ !!! *12* !!! ][ 127 ][ 31 ][ 22 ]]
[[ short->string ][ !!! *13* !!! ][ 129 ][ 31 ][ 22 ]]
[[ long int->string ][ !!! *12* !!! ][ 125 ][ 30 ][ 22 ]]
[[ long long->string ][ !!! *13* !!! ][ 127 ][ 34 ][ 24 ]]
[[ unsigned int->string ][ !!! *13* !!! ][ 127 ][ 27 ][ 21 ]]
[[ unsigned short->string ][ !!! *12* !!! ][ 127 ][ 28 ][ 22 ]]
[[ unsigned long int->string ][ !!! *12* !!! ][ 131 ][ 27 ][ 22 ]]
[[ unsigned long long->string ][ !!! *12* !!! ][ 125 ][ 28 ][ 24 ]]
[[ float->string ][ 51 ][ 200 ][ 81 ][ !!! *40* !!! ]]
[[ double->string ][ 56 ][ 194 ][ 82 ][ !!! *48* !!! ]]
[[ long double->string ][ 65 ][ 220 ][ 82 ][ !!! *41* !!! ]]
[[ char*->char ][ !!! *<1* !!! ][ 104 ][ 10 ][ 9 ]]
[[ char*->signed char ][ !!! *<1* !!! ][ 101 ][ 10 ][ 11 ]]
[[ char*->unsigned char ][ !!! *<1* !!! ][ 99 ][ 10 ][ 12 ]]
[[ char*->int ][ !!! *6* !!! ][ 112 ][ 23 ][ 24 ]]
[[ char*->short ][ !!! *6* !!! ][ 115 ][ 21 ][ 23 ]]
[[ char*->long int ][ !!! *8* !!! ][ 111 ][ 21 ][ 24 ]]
[[ char*->long long ][ !!! *9* !!! ][ 112 ][ 21 ][ 30 ]]
[[ char*->unsigned int ][ !!! *7* !!! ][ 112 ][ 22 ][ 24 ]]
[[ char*->unsigned short ][ !!! *6* !!! ][ 119 ][ 19 ][ 23 ]]
[[ char*->unsigned long int ][ !!! *7* !!! ][ 115 ][ 22 ][ 23 ]]
[[ char*->unsigned long long ][ !!! *7* !!! ][ 115 ][ 20 ][ 23 ]]
[[ char*->float ][ !!! *12* !!! ][ 153 ][ 54 ][ 39 ]]
[[ char*->double ][ !!! *12* !!! ][ 153 ][ 61 ][ 41 ]]
[[ char*->long double ][ 108 ][ 160 ][ 61 ][ !!! *49* !!! ]]
[[ char*->array<char, 50> ][ !!! *<1* !!! ][ 107 ][ 20 ][ 14 ]]
[[ char*->string ][ !!! *7* !!! ][ 123 ][ 26 ][ --- ]]
[[ char*->container::string ][ !!! *2* !!! ][ 121 ][ 24 ][ --- ]]
[[ unsigned char*->char ][ !!! *<1* !!! ][ 97 ][ 10 ][ 9 ]]
[[ unsigned char*->signed char ][ !!! *<1* !!! ][ 98 ][ 10 ][ 12 ]]
[[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 99 ][ 11 ][ 12 ]]
[[ unsigned char*->int ][ !!! *6* !!! ][ 112 ][ 22 ][ 24 ]]
[[ unsigned char*->short ][ !!! *10* !!! ][ 111 ][ 24 ][ 24 ]]
[[ unsigned char*->long int ][ !!! *8* !!! ][ 110 ][ 23 ][ 24 ]]
[[ unsigned char*->long long ][ !!! *9* !!! ][ 115 ][ 21 ][ 25 ]]
[[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 111 ][ 24 ][ 23 ]]
[[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 118 ][ 19 ][ 23 ]]
[[ unsigned char*->unsigned long int ][ !!! *8* !!! ][ 112 ][ 21 ][ 23 ]]
[[ unsigned char*->unsigned long long ][ !!! *13* !!! ][ 109 ][ 20 ][ 23 ]]
[[ unsigned char*->float ][ !!! *12* !!! ][ 154 ][ 56 ][ 39 ]]
[[ unsigned char*->double ][ !!! *17* !!! ][ 150 ][ 58 ][ 41 ]]
[[ unsigned char*->long double ][ 108 ][ 149 ][ 68 ][ !!! *43* !!! ]]
[[ unsigned char*->array<char, 50> ][ !!! *1* !!! ][ 107 ][ 19 ][ 15 ]]
[[ unsigned char*->string ][ !!! *8* !!! ][ 124 ][ 26 ][ --- ]]
[[ unsigned char*->container::string ][ !!! *4* !!! ][ 121 ][ 24 ][ --- ]]
[[ signed char*->char ][ !!! *<1* !!! ][ 99 ][ 10 ][ 9 ]]
[[ signed char*->signed char ][ !!! *<1* !!! ][ 99 ][ 10 ][ 10 ]]
[[ signed char*->unsigned char ][ !!! *<1* !!! ][ 99 ][ 10 ][ 12 ]]
[[ signed char*->int ][ !!! *6* !!! ][ 113 ][ 28 ][ 24 ]]
[[ signed char*->short ][ !!! *6* !!! ][ 110 ][ 21 ][ 25 ]]
[[ signed char*->long int ][ !!! *8* !!! ][ 110 ][ 21 ][ 24 ]]
[[ signed char*->long long ][ !!! *9* !!! ][ 116 ][ 21 ][ 24 ]]
[[ signed char*->unsigned int ][ !!! *7* !!! ][ 114 ][ 21 ][ 23 ]]
[[ signed char*->unsigned short ][ !!! *6* !!! ][ 116 ][ 20 ][ 23 ]]
[[ signed char*->unsigned long int ][ !!! *8* !!! ][ 113 ][ 27 ][ 23 ]]
[[ signed char*->unsigned long long ][ !!! *8* !!! ][ 110 ][ 20 ][ 23 ]]
[[ signed char*->float ][ !!! *12* !!! ][ 155 ][ 53 ][ 44 ]]
[[ signed char*->double ][ !!! *13* !!! ][ 150 ][ 60 ][ 42 ]]
[[ signed char*->long double ][ 108 ][ 151 ][ 62 ][ !!! *44* !!! ]]
[[ signed char*->array<char, 50> ][ !!! *1* !!! ][ 107 ][ 19 ][ 15 ]]
[[ signed char*->string ][ !!! *8* !!! ][ 124 ][ 26 ][ --- ]]
[[ signed char*->container::string ][ !!! *4* !!! ][ 121 ][ 24 ][ --- ]]
[[ iterator_range<char*>->char ][ !!! *<1* !!! ][ 103 ][ 14 ][ 10 ]]
[[ iterator_range<char*>->signed char ][ !!! *<1* !!! ][ 102 ][ 15 ][ 12 ]]
[[ iterator_range<char*>->unsigned char ][ !!! *<1* !!! ][ 102 ][ 14 ][ 12 ]]
[[ iterator_range<char*>->int ][ !!! *6* !!! ][ 115 ][ 23 ][ 24 ]]
[[ iterator_range<char*>->short ][ !!! *5* !!! ][ 110 ][ 22 ][ 24 ]]
[[ iterator_range<char*>->long int ][ !!! *7* !!! ][ 109 ][ 22 ][ 29 ]]
[[ iterator_range<char*>->long long ][ !!! *7* !!! ][ 111 ][ 24 ][ 28 ]]
[[ iterator_range<char*>->unsigned int ][ !!! *6* !!! ][ 114 ][ 22 ][ 23 ]]
[[ iterator_range<char*>->unsigned short ][ !!! *5* !!! ][ 115 ][ 20 ][ 22 ]]
[[ iterator_range<char*>->unsigned long int ][ !!! *7* !!! ][ 123 ][ 26 ][ 23 ]]
[[ iterator_range<char*>->unsigned long long ][ !!! *7* !!! ][ 110 ][ 23 ][ 24 ]]
[[ iterator_range<char*>->float ][ !!! *11* !!! ][ 153 ][ 38 ][ 38 ]]
[[ iterator_range<char*>->double ][ !!! *11* !!! ][ 140 ][ 43 ][ 40 ]]
[[ iterator_range<char*>->long double ][ 108 ][ 147 ][ !!! *41* !!! ][ 46 ]]
[[ iterator_range<char*>->array<char, 50> ][ !!! *<1* !!! ][ 109 ][ 22 ][ 15 ]]
[[ iterator_range<char*>->string ][ !!! *8* !!! ][ 122 ][ 29 ][ --- ]]
[[ iterator_range<char*>->container::string ][ !!! *3* !!! ][ 117 ][ 23 ][ --- ]]
[[ array<char, 50>->char ][ !!! *<1* !!! ][ 98 ][ 10 ][ 9 ]]
[[ array<char, 50>->signed char ][ !!! *<1* !!! ][ 99 ][ 9 ][ 12 ]]
[[ array<char, 50>->unsigned char ][ !!! *<1* !!! ][ 102 ][ 9 ][ 12 ]]
[[ array<char, 50>->int ][ !!! *6* !!! ][ 119 ][ 23 ][ 23 ]]
[[ array<char, 50>->short ][ !!! *6* !!! ][ 111 ][ 21 ][ 26 ]]
[[ array<char, 50>->long int ][ !!! *7* !!! ][ 115 ][ 20 ][ 28 ]]
[[ array<char, 50>->long long ][ !!! *9* !!! ][ 110 ][ 21 ][ 26 ]]
[[ array<char, 50>->unsigned int ][ !!! *6* !!! ][ 115 ][ 22 ][ 23 ]]
[[ array<char, 50>->unsigned short ][ !!! *6* !!! ][ 115 ][ 19 ][ 23 ]]
[[ array<char, 50>->unsigned long int ][ !!! *7* !!! ][ 118 ][ 23 ][ 23 ]]
[[ array<char, 50>->unsigned long long ][ !!! *7* !!! ][ 109 ][ 20 ][ 24 ]]
[[ array<char, 50>->float ][ !!! *12* !!! ][ 160 ][ 53 ][ 38 ]]
[[ array<char, 50>->double ][ !!! *11* !!! ][ 147 ][ 57 ][ 41 ]]
[[ array<char, 50>->long double ][ 109 ][ 154 ][ 59 ][ !!! *42* !!! ]]
[[ array<char, 50>->array<char, 50> ][ !!! *1* !!! ][ 105 ][ 19 ][ 14 ]]
[[ array<char, 50>->string ][ !!! *8* !!! ][ 129 ][ 26 ][ --- ]]
[[ array<char, 50>->container::string ][ !!! *4* !!! ][ 116 ][ 25 ][ --- ]]
[[ int->int ][ !!! *<1* !!! ][ 118 ][ 24 ][ --- ]]
[[ float->double ][ !!! *<1* !!! ][ 242 ][ 132 ][ --- ]]
[[ char->signed char ][ !!! *<1* !!! ][ 94 ][ 8 ][ --- ]]
]
[endsect]
[section GNU C++ version 4.5.3]
[table:id Performance Table ( GNU C++ version 4.5.3)
[[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]]
[[ string->char ][ !!! *<1* !!! ][ 153 ][ 15 ][ 9 ]]
[[ string->signed char ][ !!! *<1* !!! ][ 134 ][ 8 ][ 10 ]]
[[ string->unsigned char ][ !!! *<1* !!! ][ 97 ][ 8 ][ 14 ]]
[[ string->int ][ !!! *7* !!! ][ 115 ][ 22 ][ 22 ]]
[[ string->short ][ !!! *5* !!! ][ 112 ][ 19 ][ 21 ]]
[[ string->long int ][ !!! *7* !!! ][ 110 ][ 19 ][ 24 ]]
[[ string->long long ][ !!! *7* !!! ][ 115 ][ 21 ][ 23 ]]
[[ string->unsigned int ][ !!! *6* !!! ][ 113 ][ 20 ][ 23 ]]
[[ string->unsigned short ][ !!! *5* !!! ][ 116 ][ 18 ][ 23 ]]
[[ string->unsigned long int ][ !!! *7* !!! ][ 111 ][ 20 ][ 23 ]]
[[ string->unsigned long long ][ !!! *7* !!! ][ 115 ][ 18 ][ 23 ]]
[[ string->float ][ !!! *14* !!! ][ 153 ][ 55 ][ 38 ]]
[[ string->double ][ !!! *11* !!! ][ 151 ][ 60 ][ 38 ]]
[[ string->long double ][ 107 ][ 151 ][ 59 ][ !!! *44* !!! ]]
[[ string->array<char, 50> ][ !!! *<1* !!! ][ 107 ][ 18 ][ 12 ]]
[[ string->string ][ !!! *2* !!! ][ 129 ][ 49 ][ --- ]]
[[ string->container::string ][ !!! *9* !!! ][ 199 ][ 22 ][ --- ]]
[[ string->char ][ !!! *7* !!! ][ 114 ][ 27 ][ 16 ]]
[[ string->signed char ][ !!! *7* !!! ][ 116 ][ 32 ][ 23 ]]
[[ string->unsigned char ][ !!! *7* !!! ][ 114 ][ 27 ][ 22 ]]
[[ int->string ][ !!! *11* !!! ][ 125 ][ 31 ][ 21 ]]
[[ short->string ][ !!! *11* !!! ][ 126 ][ 33 ][ 21 ]]
[[ long int->string ][ !!! *11* !!! ][ 126 ][ 32 ][ 22 ]]
[[ long long->string ][ !!! *11* !!! ][ 118 ][ 30 ][ 23 ]]
[[ unsigned int->string ][ !!! *11* !!! ][ 125 ][ 31 ][ 20 ]]
[[ unsigned short->string ][ !!! *12* !!! ][ 128 ][ 30 ][ 21 ]]
[[ unsigned long int->string ][ !!! *11* !!! ][ 131 ][ 30 ][ 21 ]]
[[ unsigned long long->string ][ !!! *11* !!! ][ 127 ][ 32 ][ 23 ]]
[[ float->string ][ 49 ][ 197 ][ 92 ][ !!! *39* !!! ]]
[[ double->string ][ 56 ][ 195 ][ 80 ][ !!! *43* !!! ]]
[[ long double->string ][ 60 ][ 222 ][ 88 ][ !!! *42* !!! ]]
[[ char*->char ][ !!! *<1* !!! ][ 100 ][ 10 ][ 9 ]]
[[ char*->signed char ][ !!! *<1* !!! ][ 99 ][ 10 ][ 10 ]]
[[ char*->unsigned char ][ !!! *<1* !!! ][ 106 ][ 10 ][ 10 ]]
[[ char*->int ][ !!! *7* !!! ][ 113 ][ 23 ][ 22 ]]
[[ char*->short ][ !!! *6* !!! ][ 113 ][ 21 ][ 23 ]]
[[ char*->long int ][ !!! *8* !!! ][ 116 ][ 21 ][ 23 ]]
[[ char*->long long ][ !!! *8* !!! ][ 115 ][ 21 ][ 21 ]]
[[ char*->unsigned int ][ !!! *6* !!! ][ 114 ][ 25 ][ 22 ]]
[[ char*->unsigned short ][ !!! *6* !!! ][ 119 ][ 20 ][ 23 ]]
[[ char*->unsigned long int ][ !!! *8* !!! ][ 114 ][ 23 ][ 23 ]]
[[ char*->unsigned long long ][ !!! *7* !!! ][ 111 ][ 20 ][ 24 ]]
[[ char*->float ][ !!! *16* !!! ][ 154 ][ 54 ][ 38 ]]
[[ char*->double ][ !!! *12* !!! ][ 149 ][ 59 ][ 40 ]]
[[ char*->long double ][ 107 ][ 166 ][ 62 ][ !!! *44* !!! ]]
[[ char*->array<char, 50> ][ !!! *1* !!! ][ 108 ][ 20 ][ 12 ]]
[[ char*->string ][ !!! *8* !!! ][ 125 ][ 28 ][ --- ]]
[[ char*->container::string ][ !!! *2* !!! ][ 123 ][ 24 ][ --- ]]
[[ unsigned char*->char ][ !!! *<1* !!! ][ 104 ][ 11 ][ 9 ]]
[[ unsigned char*->signed char ][ !!! *<1* !!! ][ 106 ][ 10 ][ 10 ]]
[[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 101 ][ 10 ][ 10 ]]
[[ unsigned char*->int ][ !!! *7* !!! ][ 117 ][ 22 ][ 24 ]]
[[ unsigned char*->short ][ !!! *6* !!! ][ 111 ][ 26 ][ 22 ]]
[[ unsigned char*->long int ][ !!! *8* !!! ][ 111 ][ 23 ][ 23 ]]
[[ unsigned char*->long long ][ !!! *8* !!! ][ 114 ][ 21 ][ 23 ]]
[[ unsigned char*->unsigned int ][ !!! *7* !!! ][ 115 ][ 20 ][ 25 ]]
[[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 113 ][ 20 ][ 22 ]]
[[ unsigned char*->unsigned long int ][ !!! *8* !!! ][ 115 ][ 25 ][ 24 ]]
[[ unsigned char*->unsigned long long ][ !!! *7* !!! ][ 113 ][ 25 ][ 25 ]]
[[ unsigned char*->float ][ !!! *16* !!! ][ 158 ][ 55 ][ 38 ]]
[[ unsigned char*->double ][ !!! *12* !!! ][ 155 ][ 62 ][ 40 ]]
[[ unsigned char*->long double ][ 108 ][ 153 ][ 60 ][ !!! *41* !!! ]]
[[ unsigned char*->array<char, 50> ][ !!! *1* !!! ][ 111 ][ 19 ][ 12 ]]
[[ unsigned char*->string ][ !!! *8* !!! ][ 125 ][ 30 ][ --- ]]
[[ unsigned char*->container::string ][ !!! *4* !!! ][ 121 ][ 23 ][ --- ]]
[[ signed char*->char ][ !!! *<1* !!! ][ 98 ][ 14 ][ 9 ]]
[[ signed char*->signed char ][ !!! *<1* !!! ][ 98 ][ 11 ][ 10 ]]
[[ signed char*->unsigned char ][ !!! *<1* !!! ][ 99 ][ 10 ][ 10 ]]
[[ signed char*->int ][ !!! *7* !!! ][ 111 ][ 22 ][ 24 ]]
[[ signed char*->short ][ !!! *6* !!! ][ 123 ][ 22 ][ 23 ]]
[[ signed char*->long int ][ !!! *8* !!! ][ 112 ][ 21 ][ 23 ]]
[[ signed char*->long long ][ !!! *8* !!! ][ 114 ][ 24 ][ 24 ]]
[[ signed char*->unsigned int ][ !!! *6* !!! ][ 114 ][ 19 ][ 22 ]]
[[ signed char*->unsigned short ][ !!! *6* !!! ][ 112 ][ 21 ][ 24 ]]
[[ signed char*->unsigned long int ][ !!! *8* !!! ][ 114 ][ 23 ][ 22 ]]
[[ signed char*->unsigned long long ][ !!! *8* !!! ][ 116 ][ 22 ][ 24 ]]
[[ signed char*->float ][ !!! *16* !!! ][ 156 ][ 55 ][ 38 ]]
[[ signed char*->double ][ !!! *12* !!! ][ 151 ][ 59 ][ 39 ]]
[[ signed char*->long double ][ 111 ][ 159 ][ 60 ][ !!! *44* !!! ]]
[[ signed char*->array<char, 50> ][ !!! *1* !!! ][ 107 ][ 24 ][ 12 ]]
[[ signed char*->string ][ !!! *8* !!! ][ 122 ][ 28 ][ --- ]]
[[ signed char*->container::string ][ !!! *4* !!! ][ 122 ][ 23 ][ --- ]]
[[ iterator_range<char*>->char ][ !!! *<1* !!! ][ 103 ][ 13 ][ 10 ]]
[[ iterator_range<char*>->signed char ][ !!! *<1* !!! ][ 103 ][ 13 ][ 10 ]]
[[ iterator_range<char*>->unsigned char ][ !!! *<1* !!! ][ 104 ][ 14 ][ 10 ]]
[[ iterator_range<char*>->int ][ !!! *6* !!! ][ 115 ][ 23 ][ 24 ]]
[[ iterator_range<char*>->short ][ !!! *7* !!! ][ 111 ][ 21 ][ 24 ]]
[[ iterator_range<char*>->long int ][ !!! *7* !!! ][ 108 ][ 21 ][ 23 ]]
[[ iterator_range<char*>->long long ][ !!! *7* !!! ][ 114 ][ 24 ][ 23 ]]
[[ iterator_range<char*>->unsigned int ][ !!! *6* !!! ][ 111 ][ 22 ][ 23 ]]
[[ iterator_range<char*>->unsigned short ][ !!! *5* !!! ][ 114 ][ 20 ][ 23 ]]
[[ iterator_range<char*>->unsigned long int ][ !!! *7* !!! ][ 119 ][ 25 ][ 24 ]]
[[ iterator_range<char*>->unsigned long long ][ !!! *7* !!! ][ 110 ][ 20 ][ 24 ]]
[[ iterator_range<char*>->float ][ !!! *15* !!! ][ 148 ][ 38 ][ 40 ]]
[[ iterator_range<char*>->double ][ !!! *10* !!! ][ 146 ][ 41 ][ 40 ]]
[[ iterator_range<char*>->long double ][ 103 ][ 138 ][ !!! *39* !!! ][ 42 ]]
[[ iterator_range<char*>->array<char, 50> ][ !!! *<1* !!! ][ 109 ][ 22 ][ 13 ]]
[[ iterator_range<char*>->string ][ !!! *7* !!! ][ 121 ][ 32 ][ --- ]]
[[ iterator_range<char*>->container::string ][ !!! *3* !!! ][ 120 ][ 24 ][ --- ]]
[[ array<char, 50>->char ][ !!! *<1* !!! ][ 102 ][ 9 ][ 9 ]]
[[ array<char, 50>->signed char ][ !!! *<1* !!! ][ 97 ][ 9 ][ 10 ]]
[[ array<char, 50>->unsigned char ][ !!! *<1* !!! ][ 99 ][ 9 ][ 10 ]]
[[ array<char, 50>->int ][ !!! *7* !!! ][ 114 ][ 22 ][ 23 ]]
[[ array<char, 50>->short ][ !!! *6* !!! ][ 116 ][ 21 ][ 23 ]]
[[ array<char, 50>->long int ][ !!! *7* !!! ][ 109 ][ 20 ][ 23 ]]
[[ array<char, 50>->long long ][ !!! *7* !!! ][ 114 ][ 21 ][ 23 ]]
[[ array<char, 50>->unsigned int ][ !!! *7* !!! ][ 119 ][ 20 ][ 25 ]]
[[ array<char, 50>->unsigned short ][ !!! *6* !!! ][ 120 ][ 20 ][ 23 ]]
[[ array<char, 50>->unsigned long int ][ !!! *7* !!! ][ 113 ][ 20 ][ 21 ]]
[[ array<char, 50>->unsigned long long ][ !!! *7* !!! ][ 112 ][ 20 ][ 24 ]]
[[ array<char, 50>->float ][ !!! *16* !!! ][ 155 ][ 57 ][ 38 ]]
[[ array<char, 50>->double ][ !!! *11* !!! ][ 152 ][ 59 ][ 42 ]]
[[ array<char, 50>->long double ][ 107 ][ 152 ][ 60 ][ !!! *41* !!! ]]
[[ array<char, 50>->array<char, 50> ][ !!! *1* !!! ][ 111 ][ 20 ][ 12 ]]
[[ array<char, 50>->string ][ !!! *8* !!! ][ 123 ][ 36 ][ --- ]]
[[ array<char, 50>->container::string ][ !!! *4* !!! ][ 128 ][ 23 ][ --- ]]
[[ int->int ][ !!! *<1* !!! ][ 118 ][ 26 ][ --- ]]
[[ float->double ][ !!! *<1* !!! ][ 233 ][ 120 ][ --- ]]
[[ char->signed char ][ !!! *<1* !!! ][ 97 ][ 8 ][ --- ]]
]
[endsect]
[section GNU C++ version 4.4.7]
[table:id Performance Table ( GNU C++ version 4.4.7)
[[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]]
[[ string->char ][ !!! *<1* !!! ][ 111 ][ 8 ][ 9 ]]
[[ string->signed char ][ !!! *<1* !!! ][ 100 ][ 8 ][ 10 ]]
[[ string->unsigned char ][ !!! *<1* !!! ][ 102 ][ 8 ][ 11 ]]
[[ string->int ][ !!! *6* !!! ][ 114 ][ 21 ][ 23 ]]
[[ string->short ][ !!! *5* !!! ][ 120 ][ 21 ][ 29 ]]
[[ string->long int ][ !!! *7* !!! ][ 114 ][ 22 ][ 26 ]]
[[ string->long long ][ !!! *7* !!! ][ 118 ][ 21 ][ 23 ]]
[[ string->unsigned int ][ !!! *7* !!! ][ 115 ][ 21 ][ 23 ]]
[[ string->unsigned short ][ !!! *5* !!! ][ 119 ][ 18 ][ 22 ]]
[[ string->unsigned long int ][ !!! *7* !!! ][ 115 ][ 20 ][ 23 ]]
[[ string->unsigned long long ][ !!! *9* !!! ][ 116 ][ 26 ][ 24 ]]
[[ string->float ][ !!! *12* !!! ][ 165 ][ 53 ][ 40 ]]
[[ string->double ][ !!! *12* !!! ][ 154 ][ 54 ][ 40 ]]
[[ string->long double ][ 112 ][ 148 ][ 61 ][ !!! *45* !!! ]]
[[ string->array<char, 50> ][ !!! *<1* !!! ][ 120 ][ 19 ][ 14 ]]
[[ string->string ][ !!! *2* !!! ][ 141 ][ 55 ][ --- ]]
[[ string->container::string ][ !!! *2* !!! ][ 164 ][ 36 ][ --- ]]
[[ string->char ][ !!! *7* !!! ][ 161 ][ 24 ][ 18 ]]
[[ string->signed char ][ !!! *6* !!! ][ 109 ][ 25 ][ 24 ]]
[[ string->unsigned char ][ !!! *6* !!! ][ 109 ][ 25 ][ 25 ]]
[[ int->string ][ !!! *11* !!! ][ 128 ][ 32 ][ 23 ]]
[[ short->string ][ !!! *12* !!! ][ 136 ][ 54 ][ 34 ]]
[[ long int->string ][ !!! *15* !!! ][ 187 ][ 41 ][ 23 ]]
[[ long long->string ][ !!! *11* !!! ][ 128 ][ 30 ][ 29 ]]
[[ unsigned int->string ][ !!! *13* !!! ][ 124 ][ 29 ][ 23 ]]
[[ unsigned short->string ][ !!! *11* !!! ][ 128 ][ 30 ][ 22 ]]
[[ unsigned long int->string ][ !!! *11* !!! ][ 131 ][ 30 ][ 22 ]]
[[ unsigned long long->string ][ !!! *11* !!! ][ 133 ][ 33 ][ 29 ]]
[[ float->string ][ 52 ][ 187 ][ 90 ][ !!! *39* !!! ]]
[[ double->string ][ 58 ][ 190 ][ 86 ][ !!! *45* !!! ]]
[[ long double->string ][ 70 ][ 218 ][ 88 ][ !!! *47* !!! ]]
[[ char*->char ][ !!! *<1* !!! ][ 99 ][ 11 ][ 9 ]]
[[ char*->signed char ][ !!! *<1* !!! ][ 99 ][ 11 ][ 10 ]]
[[ char*->unsigned char ][ !!! *<1* !!! ][ 100 ][ 12 ][ 10 ]]
[[ char*->int ][ !!! *6* !!! ][ 117 ][ 23 ][ 21 ]]
[[ char*->short ][ !!! *6* !!! ][ 115 ][ 28 ][ 23 ]]
[[ char*->long int ][ !!! *7* !!! ][ 119 ][ 22 ][ 24 ]]
[[ char*->long long ][ !!! *7* !!! ][ 114 ][ 23 ][ 22 ]]
[[ char*->unsigned int ][ !!! *6* !!! ][ 113 ][ 21 ][ 21 ]]
[[ char*->unsigned short ][ !!! *6* !!! ][ 120 ][ 21 ][ 21 ]]
[[ char*->unsigned long int ][ !!! *7* !!! ][ 117 ][ 25 ][ 23 ]]
[[ char*->unsigned long long ][ !!! *7* !!! ][ 119 ][ 23 ][ 21 ]]
[[ char*->float ][ !!! *13* !!! ][ 160 ][ 61 ][ 36 ]]
[[ char*->double ][ !!! *13* !!! ][ 152 ][ 54 ][ 40 ]]
[[ char*->long double ][ 116 ][ 173 ][ 58 ][ !!! *43* !!! ]]
[[ char*->array<char, 50> ][ !!! *1* !!! ][ 121 ][ 20 ][ 12 ]]
[[ char*->string ][ !!! *7* !!! ][ 126 ][ 29 ][ --- ]]
[[ char*->container::string ][ !!! *2* !!! ][ 119 ][ 27 ][ --- ]]
[[ unsigned char*->char ][ !!! *<1* !!! ][ 96 ][ 12 ][ 9 ]]
[[ unsigned char*->signed char ][ !!! *<1* !!! ][ 95 ][ 11 ][ 12 ]]
[[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 95 ][ 12 ][ 12 ]]
[[ unsigned char*->int ][ !!! *6* !!! ][ 113 ][ 27 ][ 24 ]]
[[ unsigned char*->short ][ !!! *6* !!! ][ 120 ][ 23 ][ 21 ]]
[[ unsigned char*->long int ][ !!! *7* !!! ][ 114 ][ 22 ][ 23 ]]
[[ unsigned char*->long long ][ !!! *7* !!! ][ 114 ][ 23 ][ 23 ]]
[[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 115 ][ 23 ][ 23 ]]
[[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 120 ][ 21 ][ 23 ]]
[[ unsigned char*->unsigned long int ][ !!! *7* !!! ][ 117 ][ 23 ][ 21 ]]
[[ unsigned char*->unsigned long long ][ !!! *7* !!! ][ 121 ][ 23 ][ 21 ]]
[[ unsigned char*->float ][ !!! *12* !!! ][ 161 ][ 58 ][ 39 ]]
[[ unsigned char*->double ][ !!! *13* !!! ][ 153 ][ 54 ][ 38 ]]
[[ unsigned char*->long double ][ 110 ][ 150 ][ 62 ][ !!! *43* !!! ]]
[[ unsigned char*->array<char, 50> ][ !!! *1* !!! ][ 113 ][ 20 ][ 12 ]]
[[ unsigned char*->string ][ !!! *8* !!! ][ 124 ][ 30 ][ --- ]]
[[ unsigned char*->container::string ][ !!! *3* !!! ][ 118 ][ 27 ][ --- ]]
[[ signed char*->char ][ !!! *<1* !!! ][ 99 ][ 11 ][ 9 ]]
[[ signed char*->signed char ][ !!! *<1* !!! ][ 102 ][ 12 ][ 10 ]]
[[ signed char*->unsigned char ][ !!! *<1* !!! ][ 99 ][ 12 ][ 10 ]]
[[ signed char*->int ][ !!! *6* !!! ][ 114 ][ 30 ][ 23 ]]
[[ signed char*->short ][ !!! *6* !!! ][ 118 ][ 23 ][ 23 ]]
[[ signed char*->long int ][ !!! *7* !!! ][ 119 ][ 22 ][ 21 ]]
[[ signed char*->long long ][ !!! *7* !!! ][ 114 ][ 23 ][ 26 ]]
[[ signed char*->unsigned int ][ !!! *6* !!! ][ 114 ][ 26 ][ 23 ]]
[[ signed char*->unsigned short ][ !!! *6* !!! ][ 121 ][ 22 ][ 23 ]]
[[ signed char*->unsigned long int ][ !!! *7* !!! ][ 126 ][ 23 ][ 21 ]]
[[ signed char*->unsigned long long ][ !!! *7* !!! ][ 114 ][ 22 ][ 21 ]]
[[ signed char*->float ][ !!! *12* !!! ][ 163 ][ 57 ][ 39 ]]
[[ signed char*->double ][ !!! *13* !!! ][ 156 ][ 53 ][ 40 ]]
[[ signed char*->long double ][ 112 ][ 156 ][ 56 ][ !!! *42* !!! ]]
[[ signed char*->array<char, 50> ][ !!! *1* !!! ][ 117 ][ 20 ][ 12 ]]
[[ 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* !!! ][ 112 ][ 27 ][ --- ]]
[[ iterator_range<char*>->char ][ !!! *<1* !!! ][ 103 ][ 14 ][ 9 ]]
[[ iterator_range<char*>->signed char ][ !!! *<1* !!! ][ 104 ][ 16 ][ 10 ]]
[[ iterator_range<char*>->unsigned char ][ !!! *<1* !!! ][ 103 ][ 16 ][ 10 ]]
[[ iterator_range<char*>->int ][ !!! *6* !!! ][ 121 ][ 22 ][ 21 ]]
[[ iterator_range<char*>->short ][ !!! *7* !!! ][ 112 ][ 23 ][ 23 ]]
[[ iterator_range<char*>->long int ][ !!! *7* !!! ][ 115 ][ 24 ][ 23 ]]
[[ iterator_range<char*>->long long ][ !!! *7* !!! ][ 113 ][ 24 ][ 23 ]]
[[ iterator_range<char*>->unsigned int ][ !!! *6* !!! ][ 117 ][ 26 ][ 23 ]]
[[ iterator_range<char*>->unsigned short ][ !!! *5* !!! ][ 120 ][ 20 ][ 23 ]]
[[ iterator_range<char*>->unsigned long int ][ !!! *7* !!! ][ 124 ][ 28 ][ 21 ]]
[[ iterator_range<char*>->unsigned long long ][ !!! *7* !!! ][ 113 ][ 22 ][ 21 ]]
[[ iterator_range<char*>->float ][ !!! *11* !!! ][ 190 ][ 58 ][ 63 ]]
[[ iterator_range<char*>->double ][ !!! *20* !!! ][ 194 ][ 44 ][ 39 ]]
[[ iterator_range<char*>->long double ][ 116 ][ 145 ][ 46 ][ !!! *44* !!! ]]
[[ iterator_range<char*>->array<char, 50> ][ !!! *<1* !!! ][ 116 ][ 23 ][ 15 ]]
[[ iterator_range<char*>->string ][ !!! *7* !!! ][ 127 ][ 33 ][ --- ]]
[[ iterator_range<char*>->container::string ][ !!! *3* !!! ][ 112 ][ 24 ][ --- ]]
[[ array<char, 50>->char ][ !!! *<1* !!! ][ 98 ][ 11 ][ 10 ]]
[[ array<char, 50>->signed char ][ !!! *<1* !!! ][ 99 ][ 12 ][ 15 ]]
[[ array<char, 50>->unsigned char ][ !!! *<1* !!! ][ 100 ][ 11 ][ 10 ]]
[[ array<char, 50>->int ][ !!! *6* !!! ][ 114 ][ 27 ][ 22 ]]
[[ array<char, 50>->short ][ !!! *5* !!! ][ 113 ][ 23 ][ 23 ]]
[[ array<char, 50>->long int ][ !!! *7* !!! ][ 118 ][ 22 ][ 23 ]]
[[ array<char, 50>->long long ][ !!! *7* !!! ][ 114 ][ 26 ][ 23 ]]
[[ array<char, 50>->unsigned int ][ !!! *6* !!! ][ 113 ][ 27 ][ 23 ]]
[[ array<char, 50>->unsigned short ][ !!! *5* !!! ][ 124 ][ 21 ][ 23 ]]
[[ array<char, 50>->unsigned long int ][ !!! *7* !!! ][ 116 ][ 23 ][ 21 ]]
[[ array<char, 50>->unsigned long long ][ !!! *7* !!! ][ 115 ][ 22 ][ 21 ]]
[[ array<char, 50>->float ][ !!! *11* !!! ][ 162 ][ 58 ][ 36 ]]
[[ array<char, 50>->double ][ !!! *13* !!! ][ 155 ][ 54 ][ 44 ]]
[[ array<char, 50>->long double ][ 111 ][ 149 ][ 55 ][ !!! *42* !!! ]]
[[ array<char, 50>->array<char, 50> ][ !!! *1* !!! ][ 114 ][ 18 ][ 14 ]]
[[ array<char, 50>->string ][ !!! *7* !!! ][ 129 ][ 29 ][ --- ]]
[[ array<char, 50>->container::string ][ !!! *3* !!! ][ 113 ][ 26 ][ --- ]]
[[ int->int ][ !!! *<1* !!! ][ 114 ][ 25 ][ --- ]]
[[ float->double ][ !!! *<1* !!! ][ 236 ][ 121 ][ --- ]]
[[ char->signed char ][ !!! *<1* !!! ][ 97 ][ 8 ][ --- ]]
[[ 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 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* !!! ][ 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 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* !!! ][ 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 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* !!! ][ 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]
[/ END of section, generated by performance measuring program ]
[endsect]
+109 -329
View File
@@ -18,7 +18,7 @@
// with additional fixes and suggestions from Gennaro Prota,
// Beman Dawes, Dave Abrahams, Daryle Walker, Peter Dimov,
// Alexander Nasonov, Antony Polukhin, Justin Viiret, Michael Hofmann,
// Cheng Yang, Matthew Bradbury, David W. Birdsall, Pavel Korzh and other Boosters
// Cheng Yang, Matthew Bradbury, David W. Birdsall and other Boosters
// when: November 2000, March 2003, June 2005, June 2006, March 2011 - 2012
#include <boost/config.hpp>
@@ -47,12 +47,8 @@
# include <locale>
#else
# ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE
// Getting error at this point means, that your STL library is old/lame/misconfigured.
// If nothing can be done with STL library, define BOOST_LEXICAL_CAST_ASSUME_C_LOCALE,
// but beware: lexical_cast will understand only 'C' locale delimeters and thousands
// separators.
# error "Unable to use <locale> header. Define BOOST_LEXICAL_CAST_ASSUME_C_LOCALE to force "
# error "boost::lexical_cast to use only 'C' locale during conversions."
# warning "Unable to use <locale> header. boost::lexical_cast will use the 'C' locale."
# define BOOST_LEXICAL_CAST_ASSUME_C_LOCALE
# endif
#endif
@@ -73,12 +69,12 @@ namespace boost
{
// exception used to indicate runtime lexical_cast failure
class BOOST_SYMBOL_VISIBLE bad_lexical_cast :
// workaround MSVC bug with std::bad_cast when _HAS_EXCEPTIONS == 0
#if defined(BOOST_MSVC) && defined(_HAS_EXCEPTIONS) && !_HAS_EXCEPTIONS
public std::exception
#else
public std::bad_cast
#endif
// workaround MSVC bug with std::bad_cast when _HAS_EXCEPTIONS == 0
#if defined(BOOST_MSVC) && defined(_HAS_EXCEPTIONS) && !_HAS_EXCEPTIONS
public std::exception
#else
public std::bad_cast
#endif
#if defined(__BORLANDC__) && BOOST_WORKAROUND( __BORLANDC__, < 0x560 )
// under bcc32 5.5.1 bad_cast doesn't derive from exception
@@ -87,7 +83,7 @@ namespace boost
{
public:
bad_lexical_cast() BOOST_NOEXCEPT :
bad_lexical_cast() :
#ifndef BOOST_NO_TYPEID
source(&typeid(void)), target(&typeid(void))
#else
@@ -98,7 +94,7 @@ namespace boost
bad_lexical_cast(
const std::type_info &source_type_arg,
const std::type_info &target_type_arg) BOOST_NOEXCEPT :
const std::type_info &target_type_arg) :
source(&source_type_arg), target(&target_type_arg)
{
}
@@ -112,22 +108,14 @@ namespace boost
return *target;
}
#ifndef BOOST_NO_NOEXCEPT
virtual const char *what() const noexcept
#else
virtual const char *what() const throw()
#endif
{
return "bad lexical cast: "
"source type value could not be interpreted as target";
}
#ifndef BOOST_NO_NOEXCEPT
virtual ~bad_lexical_cast() BOOST_NOEXCEPT
#else
virtual ~bad_lexical_cast() throw()
#endif
{}
{
}
private:
const std::type_info *source;
const std::type_info *target;
@@ -146,16 +134,10 @@ namespace boost
}
} // namespace boost
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(__SUNPRO_CC) && !defined(__PGIC__)
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(__SUNPRO_CC)
#include <cmath>
#include <istream>
#if !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
#include <array>
#endif
#include <boost/array.hpp>
#include <boost/numeric/conversion/cast.hpp>
#include <boost/type_traits/make_unsigned.hpp>
#include <boost/type_traits/is_signed.hpp>
@@ -186,13 +168,13 @@ namespace boost {
{
typedef CharT type;
};
template <>
struct widest_char< not_a_character_type, not_a_character_type >
{
typedef char type;
};
}
}
namespace detail // is_char_or_wchar<...> and stream_char<...> templates
{
@@ -242,68 +224,42 @@ namespace boost {
typedef char type;
};
template <typename CharT>
template<typename CharT>
struct stream_char<CharT*>
{
typedef BOOST_DEDUCED_TYPENAME stream_char<CharT>::type type;
};
template <typename CharT>
template<typename CharT>
struct stream_char<const CharT*>
{
typedef BOOST_DEDUCED_TYPENAME stream_char<CharT>::type type;
};
template <typename CharT>
template<typename CharT>
struct stream_char<iterator_range<CharT*> >
{
typedef BOOST_DEDUCED_TYPENAME stream_char<CharT*>::type type;
};
template <typename CharT>
template<typename CharT>
struct stream_char<iterator_range<const CharT*> >
{
typedef BOOST_DEDUCED_TYPENAME stream_char<const CharT*>::type type;
};
template <class CharT, class Traits, class Alloc>
template<class CharT, class Traits, class Alloc>
struct stream_char< std::basic_string<CharT, Traits, Alloc> >
{
typedef CharT type;
};
template <class CharT, class Traits, class Alloc>
template<class CharT, class Traits, class Alloc>
struct stream_char< ::boost::container::basic_string<CharT, Traits, Alloc> >
{
typedef CharT type;
};
template<typename CharT, std::size_t N>
struct stream_char<boost::array<CharT, N> >
{
typedef BOOST_DEDUCED_TYPENAME stream_char<CharT>::type type;
};
template<typename CharT, std::size_t N>
struct stream_char<boost::array<const CharT, N> >
{
typedef BOOST_DEDUCED_TYPENAME stream_char<CharT>::type type;
};
#if !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
template <typename CharT, std::size_t N>
struct stream_char<std::array<CharT, N> >
{
typedef BOOST_DEDUCED_TYPENAME stream_char<CharT>::type type;
};
template <typename CharT, std::size_t N>
struct stream_char<std::array<const CharT, N> >
{
typedef BOOST_DEDUCED_TYPENAME stream_char<CharT>::type type;
};
#endif // !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
#if !defined(BOOST_LCAST_NO_WCHAR_T) && defined(BOOST_NO_INTRINSIC_WCHAR_T)
template<>
struct stream_char<wchar_t>
@@ -474,7 +430,7 @@ namespace boost {
// -1.23456789e-123456
// ^ sign
// ^ leading digit
// ^ decimal point
// ^ decimal point
// ^^^^^^^^ lcast_precision<Source>::value
// ^ "e"
// ^ exponent sign
@@ -582,10 +538,10 @@ namespace boost {
#endif
template<class T>
inline
BOOST_DEDUCED_TYPENAME make_unsigned<T>::type lcast_to_unsigned(T value) BOOST_NOEXCEPT
BOOST_DEDUCED_TYPENAME make_unsigned<T>::type lcast_to_unsigned(T value)
{
typedef BOOST_DEDUCED_TYPENAME make_unsigned<T>::type result_type;
const result_type uvalue = static_cast<result_type>(value);
result_type uvalue = static_cast<result_type>(value);
return value < 0 ? -uvalue : uvalue;
}
#if (defined _MSC_VER)
@@ -789,7 +745,7 @@ namespace boost {
namespace detail
{
template <class CharT>
bool lc_iequal(const CharT* val, const CharT* lcase, const CharT* ucase, unsigned int len) BOOST_NOEXCEPT {
bool lc_iequal(const CharT* val, const CharT* lcase, const CharT* ucase, unsigned int len) {
for( unsigned int i=0; i < len; ++i ) {
if ( val[i] != lcase[i] && val[i] != ucase[i] ) return false;
}
@@ -802,7 +758,7 @@ namespace boost {
inline bool parse_inf_nan_impl(const CharT* begin, const CharT* end, T& value
, const CharT* lc_NAN, const CharT* lc_nan
, const CharT* lc_INFINITY, const CharT* lc_infinity
, const CharT opening_brace, const CharT closing_brace) BOOST_NOEXCEPT
, const CharT opening_brace, const CharT closing_brace)
{
using namespace std;
if (begin == end) return false;
@@ -858,7 +814,7 @@ namespace boost {
template <class CharT, class T>
bool put_inf_nan_impl(CharT* begin, CharT*& end, const T& value
, const CharT* lc_nan
, const CharT* lc_infinity) BOOST_NOEXCEPT
, const CharT* lc_infinity)
{
using namespace std;
const CharT minus = lcast_char_constants<CharT>::minus;
@@ -892,7 +848,7 @@ namespace boost {
#ifndef BOOST_LCAST_NO_WCHAR_T
template <class T>
bool parse_inf_nan(const wchar_t* begin, const wchar_t* end, T& value) BOOST_NOEXCEPT
bool parse_inf_nan(const wchar_t* begin, const wchar_t* end, T& value)
{
return parse_inf_nan_impl(begin, end, value
, L"NAN", L"nan"
@@ -901,7 +857,7 @@ namespace boost {
}
template <class T>
bool put_inf_nan(wchar_t* begin, wchar_t*& end, const T& value) BOOST_NOEXCEPT
bool put_inf_nan(wchar_t* begin, wchar_t*& end, const T& value)
{
return put_inf_nan_impl(begin, end, value, L"nan", L"infinity");
}
@@ -909,7 +865,7 @@ namespace boost {
#endif
#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS)
template <class T>
bool parse_inf_nan(const char16_t* begin, const char16_t* end, T& value) BOOST_NOEXCEPT
bool parse_inf_nan(const char16_t* begin, const char16_t* end, T& value)
{
return parse_inf_nan_impl(begin, end, value
, u"NAN", u"nan"
@@ -918,14 +874,14 @@ namespace boost {
}
template <class T>
bool put_inf_nan(char16_t* begin, char16_t*& end, const T& value) BOOST_NOEXCEPT
bool put_inf_nan(char16_t* begin, char16_t*& end, const T& value)
{
return put_inf_nan_impl(begin, end, value, u"nan", u"infinity");
}
#endif
#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS)
template <class T>
bool parse_inf_nan(const char32_t* begin, const char32_t* end, T& value) BOOST_NOEXCEPT
bool parse_inf_nan(const char32_t* begin, const char32_t* end, T& value)
{
return parse_inf_nan_impl(begin, end, value
, U"NAN", U"nan"
@@ -934,14 +890,14 @@ namespace boost {
}
template <class T>
bool put_inf_nan(char32_t* begin, char32_t*& end, const T& value) BOOST_NOEXCEPT
bool put_inf_nan(char32_t* begin, char32_t*& end, const T& value)
{
return put_inf_nan_impl(begin, end, value, U"nan", U"infinity");
}
#endif
template <class CharT, class T>
bool parse_inf_nan(const CharT* begin, const CharT* end, T& value) BOOST_NOEXCEPT
bool parse_inf_nan(const CharT* begin, const CharT* end, T& value)
{
return parse_inf_nan_impl(begin, end, value
, "NAN", "nan"
@@ -950,7 +906,7 @@ namespace boost {
}
template <class CharT, class T>
bool put_inf_nan(CharT* begin, CharT*& end, const T& value) BOOST_NOEXCEPT
bool put_inf_nan(CharT* begin, CharT*& end, const T& value)
{
return put_inf_nan_impl(begin, end, value, "nan", "infinity");
}
@@ -1020,11 +976,11 @@ namespace boost {
/* Getting the plus/minus sign */
bool has_minus = false;
if (Traits::eq(*begin, minus) ) {
if ( *begin == minus ) {
++ begin;
has_minus = true;
if (begin == end) return false;
} else if (Traits::eq(*begin, plus) ) {
} else if ( *begin == plus ) {
++begin;
if (begin == end) return false;
}
@@ -1043,7 +999,7 @@ namespace boost {
/* We allow no thousand_separators after decimal point */
mantissa_type tmp_mantissa = mantissa * 10u;
if (Traits::eq(*begin, lowercase_e) || Traits::eq(*begin, capital_e)) break;
if ( *begin == lowercase_e || *begin == capital_e ) break;
if ( *begin < czero || *begin >= czero + 10 ) return false;
if ( is_mantissa_full
|| tmp_mantissa / 10u != mantissa
@@ -1082,7 +1038,7 @@ namespace boost {
found_number_before_exp = true;
++ length_since_last_delim;
} else if (Traits::eq(*begin, decimal_point) || Traits::eq(*begin, lowercase_e) || Traits::eq(*begin, capital_e)) {
} else if ( *begin == decimal_point || *begin == lowercase_e || *begin == capital_e) {
#ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE
/* If ( we need to check grouping
* and ( grouping missmatches
@@ -1100,7 +1056,7 @@ namespace boost {
) return false;
#endif
if(Traits::eq(*begin, decimal_point)) {
if(*begin == decimal_point) {
++ begin;
found_decimal = true;
if (!found_number_before_exp && begin==end) return false;
@@ -1111,7 +1067,7 @@ namespace boost {
}
}
#ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE
else if (grouping_size && Traits::eq(*begin, thousands_sep)){
else if (grouping_size && *begin == thousands_sep){
if(found_grouping)
{
/* It is not he first time, when we find thousands separator,
@@ -1153,16 +1109,16 @@ namespace boost {
}
// Exponent found
if ( begin != end && (Traits::eq(*begin, lowercase_e) || Traits::eq(*begin, capital_e)) ) {
if ( begin != end && ( *begin == lowercase_e || *begin == capital_e ) ) {
++ begin;
if ( begin == end ) return false;
bool exp_has_minus = false;
if(Traits::eq(*begin, minus)) {
if( *begin == minus ) {
exp_has_minus = true;
++ begin;
if ( begin == end ) return false;
} else if (Traits::eq(*begin, plus)) {
} else if (*begin == plus ) {
++ begin;
if ( begin == end ) return false;
}
@@ -1270,7 +1226,7 @@ namespace boost {
void operator=(lexical_stream_limited_src const&);
/************************************ HELPER FUNCTIONS FOR OPERATORS << ( ... ) ********************************/
bool shl_char(CharT ch) BOOST_NOEXCEPT
bool shl_char(CharT ch)
{
Traits::assign(*start, ch);
finish = start + 1;
@@ -1282,13 +1238,13 @@ namespace boost {
bool shl_char(T ch)
{
BOOST_STATIC_ASSERT_MSG(( sizeof(T) <= sizeof(CharT)) ,
"boost::lexical_cast does not support narrowing of char types."
"boost::lexical_cast does not support conversions from wide character to char types."
"Use boost::locale instead" );
#ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE
std::locale loc;
CharT const w = BOOST_USE_FACET(std::ctype<CharT>, loc).widen(ch);
wchar_t w = BOOST_USE_FACET(std::ctype<wchar_t>, loc).widen(ch);
#else
CharT const w = ch;
wchar_t w = ch;
#endif
Traits::assign(*start, w);
finish = start + 1;
@@ -1296,28 +1252,23 @@ namespace boost {
}
#endif
bool shl_char_array(CharT const* str) BOOST_NOEXCEPT
bool shl_char_array(CharT const* str)
{
start = const_cast<CharT*>(str);
finish = start + Traits::length(str);
return true;
}
#ifndef BOOST_LCAST_NO_WCHAR_T
template <class T>
bool shl_char_array(T const* str)
{
BOOST_STATIC_ASSERT_MSG(( sizeof(T) <= sizeof(CharT)),
"boost::lexical_cast does not support narrowing of char types."
"boost::lexical_cast does not support conversions from wide characters to char types."
"Use boost::locale instead" );
return shl_input_streamable(str);
}
bool shl_char_array_limited(CharT const* str, std::size_t max_size) BOOST_NOEXCEPT
{
start = const_cast<CharT*>(str);
finish = std::find(start, start + max_size, Traits::to_char_type(0));
return true;
}
#endif
template<typename InputStreamable>
bool shl_input_streamable(InputStreamable& input)
@@ -1356,30 +1307,25 @@ namespace boost {
return shl_input_streamable(val);
}
#if (defined _MSC_VER)
# pragma warning( push )
// C4996: This function or variable may be unsafe. Consider using sprintf_s instead
# pragma warning( disable : 4996 )
#endif
static bool shl_real_type(float val, char* begin, char*& end)
{ using namespace std;
if (put_inf_nan(begin, end, val)) return true;
end = begin;
const double val_as_double = val;
end = begin +
#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)
sprintf_s(begin, end-begin,
#else
sprintf(begin,
#endif
"%.*g", static_cast<int>(boost::detail::lcast_get_precision<float>()), val_as_double);
end += sprintf(begin,"%.*g", static_cast<int>(boost::detail::lcast_get_precision<float>()), val_as_double);
return end > begin;
}
static bool shl_real_type(double val, char* begin, char*& end)
{ using namespace std;
if (put_inf_nan(begin, end, val)) return true;
end = begin +
#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)
sprintf_s(begin, end-begin,
#else
sprintf(begin,
#endif
"%.*g", static_cast<int>(boost::detail::lcast_get_precision<double>()), val);
end = begin;
end += sprintf(begin,"%.*g", static_cast<int>(boost::detail::lcast_get_precision<double>()), val);
return end > begin;
}
@@ -1387,17 +1333,16 @@ namespace boost {
static bool shl_real_type(long double val, char* begin, char*& end)
{ using namespace std;
if (put_inf_nan(begin, end, val)) return true;
end = begin +
#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)
sprintf_s(begin, end-begin,
#else
sprintf(begin,
#endif
"%.*Lg", static_cast<int>(boost::detail::lcast_get_precision<long double>()), val );
end = begin;
end += sprintf(begin,"%.*Lg", static_cast<int>(boost::detail::lcast_get_precision<long double>()), val );
return end > begin;
}
#endif
#if (defined _MSC_VER)
# pragma warning( pop )
#endif
#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_SWPRINTF) && !defined(__MINGW32__)
static bool shl_real_type(float val, wchar_t* begin, wchar_t*& end)
@@ -1431,7 +1376,7 @@ namespace boost {
/************************************ OPERATORS << ( ... ) ********************************/
public:
template<class Alloc>
bool operator<<(std::basic_string<CharT,Traits,Alloc> const& str) BOOST_NOEXCEPT
bool operator<<(std::basic_string<CharT,Traits,Alloc> const& str)
{
start = const_cast<CharT*>(str.data());
finish = start + str.length();
@@ -1439,14 +1384,14 @@ namespace boost {
}
template<class Alloc>
bool operator<<(::boost::container::basic_string<CharT,Traits,Alloc> const& str) BOOST_NOEXCEPT
bool operator<<(::boost::container::basic_string<CharT,Traits,Alloc> const& str)
{
start = const_cast<CharT*>(str.data());
finish = start + str.length();
return true;
}
bool operator<<(bool value) BOOST_NOEXCEPT
bool operator<<(bool value)
{
CharT const czero = lcast_char_constants<CharT>::zero;
Traits::assign(*start, Traits::to_char_type(czero + value));
@@ -1454,21 +1399,21 @@ namespace boost {
return true;
}
bool operator<<(const iterator_range<CharT*>& rng) BOOST_NOEXCEPT
bool operator<<(const iterator_range<CharT*>& rng)
{
start = rng.begin();
finish = rng.end();
return true;
return true;
}
bool operator<<(const iterator_range<const CharT*>& rng) BOOST_NOEXCEPT
bool operator<<(const iterator_range<const CharT*>& rng)
{
start = const_cast<CharT*>(rng.begin());
finish = const_cast<CharT*>(rng.end());
return true;
return true;
}
bool operator<<(const iterator_range<const signed char*>& rng) BOOST_NOEXCEPT
bool operator<<(const iterator_range<const signed char*>& rng)
{
return (*this) << iterator_range<char*>(
const_cast<char*>(reinterpret_cast<const char*>(rng.begin())),
@@ -1476,7 +1421,7 @@ namespace boost {
);
}
bool operator<<(const iterator_range<const unsigned char*>& rng) BOOST_NOEXCEPT
bool operator<<(const iterator_range<const unsigned char*>& rng)
{
return (*this) << iterator_range<char*>(
const_cast<char*>(reinterpret_cast<const char*>(rng.begin())),
@@ -1484,7 +1429,7 @@ namespace boost {
);
}
bool operator<<(const iterator_range<signed char*>& rng) BOOST_NOEXCEPT
bool operator<<(const iterator_range<signed char*>& rng)
{
return (*this) << iterator_range<char*>(
reinterpret_cast<char*>(rng.begin()),
@@ -1492,7 +1437,7 @@ namespace boost {
);
}
bool operator<<(const iterator_range<unsigned char*>& rng) BOOST_NOEXCEPT
bool operator<<(const iterator_range<unsigned char*>& rng)
{
return (*this) << iterator_range<char*>(
reinterpret_cast<char*>(rng.begin()),
@@ -1549,58 +1494,8 @@ namespace boost {
return shl_real_type(static_cast<double>(val), start, finish);
#endif
}
template <std::size_t N>
bool operator<<(boost::array<CharT, N> const& input) BOOST_NOEXCEPT
{ return shl_char_array_limited(input.begin(), N); }
template <std::size_t N>
bool operator<<(boost::array<unsigned char, N> const& input) BOOST_NOEXCEPT
{ return ((*this) << reinterpret_cast<boost::array<char, N> const& >(input)); }
template <std::size_t N>
bool operator<<(boost::array<signed char, N> const& input) BOOST_NOEXCEPT
{ return ((*this) << reinterpret_cast<boost::array<char, N> const& >(input)); }
template <std::size_t N>
bool operator<<(boost::array<const CharT, N> const& input) BOOST_NOEXCEPT
{ return shl_char_array_limited(input.begin(), N); }
template <std::size_t N>
bool operator<<(boost::array<const unsigned char, N> const& input) BOOST_NOEXCEPT
{ return ((*this) << reinterpret_cast<boost::array<const char, N> const& >(input)); }
template <std::size_t N>
bool operator<<(boost::array<const signed char, N> const& input) BOOST_NOEXCEPT
{ return ((*this) << reinterpret_cast<boost::array<const char, N> const& >(input)); }
#if !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
template <std::size_t N>
bool operator<<(std::array<CharT, N> const& input) BOOST_NOEXCEPT
{ return shl_char_array_limited(input.begin(), N); }
template <std::size_t N>
bool operator<<(std::array<unsigned char, N> const& input) BOOST_NOEXCEPT
{ return ((*this) << reinterpret_cast<boost::array<char, N> const& >(input)); }
template <std::size_t N>
bool operator<<(std::array<signed char, N> const& input) BOOST_NOEXCEPT
{ return ((*this) << reinterpret_cast<boost::array<char, N> const& >(input)); }
template <std::size_t N>
bool operator<<(std::array<const CharT, N> const& input) BOOST_NOEXCEPT
{ return shl_char_array_limited(input.begin(), N); }
template <std::size_t N>
bool operator<<(std::array<const unsigned char, N> const& input) BOOST_NOEXCEPT
{ return ((*this) << reinterpret_cast<boost::array<const char, N> const& >(input)); }
template <std::size_t N>
bool operator<<(std::array<const signed char, N> const& input) BOOST_NOEXCEPT
{ return ((*this) << reinterpret_cast<boost::array<const char, N> const& >(input)); }
#endif // !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
template <class InStreamable>
template<class InStreamable>
bool operator<<(const InStreamable& input) { return shl_input_streamable(input); }
/************************************ HELPER FUNCTIONS FOR OPERATORS >> ( ... ) ********************************/
@@ -1735,10 +1630,10 @@ namespace boost {
inline bool shr_xchar(T& output)
{
BOOST_STATIC_ASSERT_MSG(( sizeof(CharT) == sizeof(T) ),
"boost::lexical_cast does not support narrowing of character types."
"boost::lexical_cast does not support conversions from wchar_t to char types."
"Use boost::locale instead" );
bool const ok = (finish - start == 1);
if (ok) {
if(ok) {
CharT out;
Traits::assign(out, *start);
output = static_cast<T>(out);
@@ -1779,69 +1674,12 @@ namespace boost {
template<class Alloc>
bool operator>>(::boost::container::basic_string<CharT,Traits,Alloc>& str) { str.assign(start, finish); return true; }
private:
template <std::size_t N, class ArrayT>
bool shr_std_array(ArrayT& output) BOOST_NOEXCEPT
{
using namespace std;
const std::size_t size = finish - start;
if (size > N - 1) { // `-1` because we need to store \0 at the end
return false;
}
memcpy(output.begin(), start, size * sizeof(CharT));
*(output.begin() + size) = Traits::to_char_type(0);
return true;
}
public:
template <std::size_t N>
bool operator>>(boost::array<CharT, N>& output) BOOST_NOEXCEPT
{
return shr_std_array<N>(output);
}
template <std::size_t N>
bool operator>>(boost::array<unsigned char, N>& output)
{
return ((*this) >> reinterpret_cast<boost::array<char, N>& >(output));
}
template <std::size_t N>
bool operator>>(boost::array<signed char, N>& output)
{
return ((*this) >> reinterpret_cast<boost::array<char, N>& >(output));
}
#if !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
template <std::size_t N>
bool operator>>(std::array<CharT, N>& output) BOOST_NOEXCEPT
{
return shr_std_array<N>(output);
}
template <std::size_t N>
bool operator>>(std::array<unsigned char, N>& output)
{
return ((*this) >> reinterpret_cast<std::array<char, N>& >(output));
}
template <std::size_t N>
bool operator>>(std::array<signed char, N>& in)
{
return ((*this) >> reinterpret_cast<std::array<char, N>& >(output));
}
#endif // !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
/*
* case "-0" || "0" || "+0" : output = false; return true;
* case "1" || "+1": output = true; return true;
* default: return false;
*/
bool operator>>(bool& output) BOOST_NOEXCEPT
bool operator>>(bool& output)
{
CharT const zero = lcast_char_constants<CharT>::zero;
CharT const plus = lcast_char_constants<CharT>::plus;
@@ -1891,10 +1729,10 @@ namespace boost {
CharT const lowercase_e = lcast_char_constants<CharT>::lowercase_e;
if ( return_value &&
(
Traits::eq(*(finish-1), lowercase_e) // 1.0e
|| Traits::eq(*(finish-1), capital_e) // 1.0E
|| Traits::eq(*(finish-1), minus) // 1.0e- or 1.0E-
|| Traits::eq(*(finish-1), plus) // 1.0e+ or 1.0E+
*(finish-1) == lowercase_e // 1.0e
|| *(finish-1) == capital_e // 1.0E
|| *(finish-1) == minus // 1.0e- or 1.0E-
|| *(finish-1) == plus // 1.0e+ or 1.0E+
)
) return false;
@@ -2019,11 +1857,11 @@ namespace boost {
};
// this metafunction evaluates to true, if we have optimized comnversion
// from Float type to Char array.
// this metafunction evaluates to true, if we have optimized comnversion
// from Float type to Char array.
// Must be in sync with lexical_stream_limited_src<Char, ...>::shl_real_type(...)
template <typename Float, typename Char>
struct is_this_float_conversion_optimized
struct is_this_float_conversion_optimized
{
typedef ::boost::type_traits::ice_and<
::boost::is_float<Float>::value,
@@ -2082,9 +1920,8 @@ namespace boost {
static inline Target lexical_cast_impl(const Source& arg)
{
typedef BOOST_DEDUCED_TYPENAME detail::array_to_pointer_decay<Source>::type src;
typedef BOOST_DEDUCED_TYPENAME ::boost::remove_cv<src>::type no_cv_src;
typedef BOOST_DEDUCED_TYPENAME detail::stream_char<Target>::type target_char_t;
typedef BOOST_DEDUCED_TYPENAME detail::stream_char<no_cv_src>::type src_char_type;
typedef BOOST_DEDUCED_TYPENAME detail::stream_char<src>::type src_char_type;
typedef BOOST_DEDUCED_TYPENAME detail::widest_char<
target_char_t, src_char_type
>::type char_type;
@@ -2100,8 +1937,13 @@ namespace boost {
"Your compiler does not have full support for char32_t" );
#endif
typedef detail::lcast_src_length<src > lcast_src_length;
std::size_t const src_len = lcast_src_length::value;
char_type buf[src_len + 1];
lcast_src_length::check_coverage();
typedef BOOST_DEDUCED_TYPENAME ::boost::detail::deduce_char_traits<
char_type, Target, no_cv_src
char_type, Target, Source
>::type traits;
typedef ::boost::type_traits::ice_and<
@@ -2112,34 +1954,25 @@ namespace boost {
> is_string_widening_required_t;
typedef ::boost::type_traits::ice_or<
::boost::is_integral<no_cv_src>::value,
::boost::detail::is_this_float_conversion_optimized<no_cv_src, char_type >::value,
::boost::is_integral<src>::value,
::boost::detail::is_this_float_conversion_optimized<src, char_type >::value,
::boost::detail::is_char_or_wchar<src_char_type >::value
> is_source_input_optimized_t;
// Target type must be default constructible
Target result;
// If we have an optimized conversion for
// Source, we do not need to construct stringbuf.
const bool requires_stringbuf = ::boost::type_traits::ice_or<
is_string_widening_required_t::value,
::boost::type_traits::ice_not< is_source_input_optimized_t::value >::value
>::value;
typedef detail::lexical_stream_limited_src<char_type, traits, requires_stringbuf > interpreter_type;
typedef detail::lcast_src_length<no_cv_src> lcast_src_length;
std::size_t const src_len = lcast_src_length::value;
char_type buf[src_len + 1];
lcast_src_length::check_coverage();
interpreter_type interpreter(buf, buf + src_len);
detail::lexical_stream_limited_src<char_type, traits, requires_stringbuf >
interpreter(buf, buf + src_len);
Target result;
// Disabling ADL, by directly specifying operators.
if(!(interpreter.operator <<(arg) && interpreter.operator >>(result)))
BOOST_LCAST_THROW_BAD_CAST(Source, Target);
return result;
}
};
@@ -2150,7 +1983,7 @@ namespace boost {
template <typename Source>
struct lexical_cast_copy
{
static inline const Source& lexical_cast_impl(const Source &arg) BOOST_NOEXCEPT
static inline Source lexical_cast_impl(const Source &arg)
{
return arg;
}
@@ -2300,59 +2133,6 @@ namespace boost {
return caster_type::lexical_cast_impl(arg);
}
template <typename Target>
inline Target lexical_cast(const char* chars, std::size_t count)
{
return ::boost::lexical_cast<Target>(
::boost::iterator_range<const char*>(chars, chars + count)
);
}
template <typename Target>
inline Target lexical_cast(const unsigned char* chars, std::size_t count)
{
return ::boost::lexical_cast<Target>(
::boost::iterator_range<const unsigned char*>(chars, chars + count)
);
}
template <typename Target>
inline Target lexical_cast(const signed char* chars, std::size_t count)
{
return ::boost::lexical_cast<Target>(
::boost::iterator_range<const signed char*>(chars, chars + count)
);
}
#ifndef BOOST_LCAST_NO_WCHAR_T
template <typename Target>
inline Target lexical_cast(const wchar_t* chars, std::size_t count)
{
return ::boost::lexical_cast<Target>(
::boost::iterator_range<const wchar_t*>(chars, chars + count)
);
}
#endif
#ifndef BOOST_NO_CHAR16_T
template <typename Target>
inline Target lexical_cast(const char16_t* chars, std::size_t count)
{
return ::boost::lexical_cast<Target>(
::boost::iterator_range<const char16_t*>(chars, chars + count)
);
}
#endif
#ifndef BOOST_NO_CHAR32_T
template <typename Target>
inline Target lexical_cast(const char32_t* chars, std::size_t count)
{
return ::boost::lexical_cast<Target>(
::boost::iterator_range<const char32_t*>(chars, chars + count)
);
}
#endif
} // namespace boost
#else // #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
@@ -2472,10 +2252,10 @@ namespace boost {
template<typename Target, typename Source>
Target lexical_cast(Source arg)
{
typedef typename detail::widest_char<
BOOST_DEDUCED_TYPENAME detail::stream_char<Target>::type
, BOOST_DEDUCED_TYPENAME detail::stream_char<Source>::type
>::type char_type;
typedef typename detail::widest_char<
BOOST_DEDUCED_TYPENAME detail::stream_char<Target>::type
, BOOST_DEDUCED_TYPENAME detail::stream_char<Source>::type
>::type char_type;
typedef std::char_traits<char_type> traits;
detail::lexical_stream<Target, Source, traits> interpreter;
+467 -42
View File
@@ -4,7 +4,7 @@
//
// Copyright Terje Sletteb and Kevlin Henney, 2005.
// Copyright Alexander Nasonov, 2006.
// Copyright Antony Polukhin, 2011-2012.
// Copyright Antony Polukhin, 2011.
//
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
@@ -57,6 +57,13 @@ struct my_allocator : std::allocator<CharT>
{
};
// Test all 65536 values if true:
bool const lcast_test_small_integral_types_completely = false;
// lcast_integral_test_counter: use when testing all values of an integral
// types is not possible. Max. portable value is 32767.
int const lcast_integral_test_counter=1000;
using namespace boost;
void test_conversion_to_char();
@@ -73,7 +80,18 @@ void test_conversion_from_wstring();
void test_conversion_to_wstring();
void test_bad_lexical_cast();
void test_no_whitespace_stripping();
void test_volatile_types_conversions();
void test_conversion_from_to_short();
void test_conversion_from_to_ushort();
void test_conversion_from_to_int();
void test_conversion_from_to_uint();
void test_conversion_from_to_long();
void test_conversion_from_to_ulong();
void test_conversion_from_to_intmax_t();
void test_conversion_from_to_uintmax_t();
#ifdef LCAST_TEST_LONGLONG
void test_conversion_from_to_longlong();
void test_conversion_from_to_ulonglong();
#endif
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
void test_traits();
void test_wtraits();
@@ -88,7 +106,7 @@ void test_char16_conversions();
#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS)
void test_char32_conversions();
#endif
void test_getting_pointer_to_function();
unit_test::test_suite *init_unit_test_suite(int, char *[])
{
@@ -110,7 +128,18 @@ unit_test::test_suite *init_unit_test_suite(int, char *[])
#endif
suite->add(BOOST_TEST_CASE(test_bad_lexical_cast));
suite->add(BOOST_TEST_CASE(test_no_whitespace_stripping));
suite->add(BOOST_TEST_CASE(test_volatile_types_conversions));
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_short));
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ushort));
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_int));
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_uint));
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_long));
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ulong));
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_intmax_t));
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_uintmax_t));
#ifdef LCAST_TEST_LONGLONG
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_longlong));
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ulonglong));
#endif
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
suite->add(BOOST_TEST_CASE(&test_traits));
suite->add(BOOST_TEST_CASE(&test_wtraits));
@@ -126,7 +155,6 @@ unit_test::test_suite *init_unit_test_suite(int, char *[])
#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS)
suite->add(BOOST_TEST_CASE(&test_char32_conversions));
#endif
suite->add(BOOST_TEST_CASE(&test_getting_pointer_to_function));
return suite;
}
@@ -371,7 +399,6 @@ void test_conversion_to_wchar_t()
BOOST_CHECK_THROW(
lexical_cast<wchar_t>(std::wstring(L"Test")), bad_lexical_cast);
#endif
BOOST_CHECK(true);
}
void test_conversion_from_wstring()
@@ -390,7 +417,6 @@ void test_conversion_from_wstring()
BOOST_CHECK_THROW(
lexical_cast<bool>(std::wstring(L"Test")), bad_lexical_cast);
#endif
BOOST_CHECK(true);
}
void test_conversion_to_wstring()
@@ -415,7 +441,6 @@ void test_conversion_to_wstring()
BOOST_CHECK(L" " == lexical_cast<std::wstring>(std::wstring(L" ")));
BOOST_CHECK(L"" == lexical_cast<std::wstring>(std::wstring(L"")));
#endif
BOOST_CHECK(true);
}
void test_bad_lexical_cast()
@@ -439,18 +464,445 @@ void test_no_whitespace_stripping()
BOOST_CHECK_THROW(lexical_cast<int>("123 "), bad_lexical_cast);
}
void test_volatile_types_conversions()
// Replace "-,999" with "-999".
template<class CharT>
std::basic_string<CharT> to_str_gcc_workaround(std::basic_string<CharT> str)
{
volatile int i1 = 100000;
BOOST_CHECK_EQUAL("100000", boost::lexical_cast<std::string>(i1));
std::locale loc;
std::numpunct<CharT> const& np = BOOST_USE_FACET(std::numpunct<CharT>, loc);
std::ctype<CharT> const& ct = BOOST_USE_FACET(std::ctype<CharT>, loc);
volatile const int i2 = 100000;
BOOST_CHECK_EQUAL("100000", boost::lexical_cast<std::string>(i2));
if(np.grouping().empty())
return str;
volatile const long int i3 = 1000000;
BOOST_CHECK_EQUAL("1000000", boost::lexical_cast<std::string>(i3));
CharT prefix[3] = { ct.widen('-'), np.thousands_sep(), CharT() };
if(str.find(prefix) != 0)
return str;
prefix[1] = CharT();
str.replace(0, 2, prefix);
return str;
}
template<class CharT, class T>
std::basic_string<CharT> to_str(T t)
{
std::basic_ostringstream<CharT> o;
o << t;
return to_str_gcc_workaround(o.str());
}
template<class T, class CharT>
void test_conversion_from_integral_to_char(CharT zero)
{
BOOST_CHECK(lexical_cast<CharT>(static_cast<T>(0)) == zero + 0);
BOOST_CHECK(lexical_cast<CharT>(static_cast<T>(1)) == zero + 1);
BOOST_CHECK(lexical_cast<CharT>(static_cast<T>(2)) == zero + 2);
BOOST_CHECK(lexical_cast<CharT>(static_cast<T>(3)) == zero + 3);
BOOST_CHECK(lexical_cast<CharT>(static_cast<T>(4)) == zero + 4);
BOOST_CHECK(lexical_cast<CharT>(static_cast<T>(5)) == zero + 5);
BOOST_CHECK(lexical_cast<CharT>(static_cast<T>(6)) == zero + 6);
BOOST_CHECK(lexical_cast<CharT>(static_cast<T>(7)) == zero + 7);
BOOST_CHECK(lexical_cast<CharT>(static_cast<T>(8)) == zero + 8);
BOOST_CHECK(lexical_cast<CharT>(static_cast<T>(9)) == zero + 9);
BOOST_CHECK_THROW(lexical_cast<CharT>(static_cast<T>(10)), bad_lexical_cast);
T t = (std::numeric_limits<T>::max)();
BOOST_CHECK_THROW(lexical_cast<CharT>(t), bad_lexical_cast);
}
template<class T, class CharT>
void test_conversion_from_char_to_integral(CharT zero)
{
BOOST_CHECK(lexical_cast<T>( static_cast<CharT>(zero + 0)) == static_cast<T>(0) );
BOOST_CHECK(lexical_cast<T>( static_cast<CharT>(zero + 1)) == static_cast<T>(1) );
BOOST_CHECK(lexical_cast<T>( static_cast<CharT>(zero + 2)) == static_cast<T>(2) );
BOOST_CHECK(lexical_cast<T>( static_cast<CharT>(zero + 3)) == static_cast<T>(3) );
BOOST_CHECK(lexical_cast<T>( static_cast<CharT>(zero + 4)) == static_cast<T>(4) );
BOOST_CHECK(lexical_cast<T>( static_cast<CharT>(zero + 5)) == static_cast<T>(5) );
BOOST_CHECK(lexical_cast<T>( static_cast<CharT>(zero + 6)) == static_cast<T>(6) );
BOOST_CHECK(lexical_cast<T>( static_cast<CharT>(zero + 7)) == static_cast<T>(7) );
BOOST_CHECK(lexical_cast<T>( static_cast<CharT>(zero + 8)) == static_cast<T>(8) );
BOOST_CHECK(lexical_cast<T>( static_cast<CharT>(zero + 9)) == static_cast<T>(9) );
BOOST_CHECK_THROW(lexical_cast<T>( static_cast<CharT>(zero + 10)), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>( static_cast<CharT>(zero - 1)), bad_lexical_cast);
}
template<class T>
void test_conversion_from_integral_to_integral()
{
T t = 0;
BOOST_CHECK(lexical_cast<T>(t) == t);
// Next two variables are used to supress warnings.
int st = 32767; unsigned int ut = st;
t = st;
BOOST_CHECK(lexical_cast<short>(t) == st);
BOOST_CHECK(lexical_cast<unsigned short>(t) == ut);
BOOST_CHECK(lexical_cast<int>(t) == st);
BOOST_CHECK(lexical_cast<unsigned int>(t) == ut);
BOOST_CHECK(lexical_cast<long>(t) == st);
BOOST_CHECK(lexical_cast<unsigned long>(t) == ut);
t = (std::numeric_limits<T>::max)();
BOOST_CHECK(lexical_cast<T>(t) == t);
t = (std::numeric_limits<T>::min)();
BOOST_CHECK(lexical_cast<T>(t) == t);
}
template<class T, class CharT>
void test_conversion_from_integral_to_string(CharT)
{
typedef std::numeric_limits<T> limits;
typedef std::basic_string<CharT> string_type;
T t;
t = (limits::min)();
BOOST_CHECK(lexical_cast<string_type>(t) == to_str<CharT>(t));
t = (limits::max)();
BOOST_CHECK(lexical_cast<string_type>(t) == to_str<CharT>(t));
if(limits::digits <= 16 && lcast_test_small_integral_types_completely)
// min and max have already been tested.
for(t = 1 + (limits::min)(); t != (limits::max)(); ++t)
BOOST_CHECK(lexical_cast<string_type>(t) == to_str<CharT>(t));
else
{
T const min_val = (limits::min)();
T const max_val = (limits::max)();
T const half_max_val = max_val / 2;
T const cnt = lcast_integral_test_counter; // to supress warnings
unsigned int const counter = cnt < half_max_val ? cnt : half_max_val;
unsigned int i;
// Test values around min:
t = min_val;
for(i = 0; i < counter; ++i, ++t)
BOOST_CHECK(lexical_cast<string_type>(t) == to_str<CharT>(t));
// Test values around max:
t = max_val;
for(i = 0; i < counter; ++i, --t)
BOOST_CHECK(lexical_cast<string_type>(t) == to_str<CharT>(t));
// Test values around zero:
if(limits::is_signed)
for(t = static_cast<T>(-counter); t < static_cast<T>(counter); ++t)
BOOST_CHECK(lexical_cast<string_type>(t) == to_str<CharT>(t));
// Test values around 100, 1000, 10000, ...
T ten_power = 100;
for(int e = 2; e <= limits::digits10; ++e, ten_power *= 10)
{
// ten_power + 100 probably never overflows
for(t = ten_power - 100; t != ten_power + 100; ++t)
BOOST_CHECK(lexical_cast<string_type>(t) == to_str<CharT>(t));
}
}
}
template<class T, class CharT>
void test_conversion_from_string_to_integral(CharT)
{
typedef std::numeric_limits<T> limits;
typedef std::basic_string<CharT> string_type;
string_type s;
string_type const zero = to_str<CharT>(0);
string_type const nine = to_str<CharT>(9);
T const min_val = (limits::min)();
T const max_val = (limits::max)();
s = to_str<CharT>(min_val);
BOOST_CHECK_EQUAL(lexical_cast<T>(s), min_val);
if(limits::is_signed)
{
BOOST_CHECK_THROW(lexical_cast<T>(s + zero), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>(s + nine), bad_lexical_cast);
}
s = to_str<CharT>(max_val);
BOOST_CHECK_EQUAL(lexical_cast<T>(s), max_val);
{
BOOST_CHECK_THROW(lexical_cast<T>(s + zero), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>(s + nine), bad_lexical_cast);
s = to_str<CharT>(max_val);
for (int i =1; i <=10; ++i) {
s[s.size()-1] += 1;
BOOST_CHECK_THROW(lexical_cast<T>( s ), bad_lexical_cast);
}
s = to_str<CharT>(max_val);
std::locale loc;
typedef std::numpunct<char> numpunct;
if ( BOOST_USE_FACET(numpunct, loc).grouping().empty() ) {
// Following tests work well for locale C
BOOST_CHECK_EQUAL(lexical_cast<T>(to_str<CharT>(0)+s), max_val);
BOOST_CHECK_EQUAL(lexical_cast<T>(to_str<CharT>(0)+to_str<CharT>(0)+s), max_val);
BOOST_CHECK_EQUAL(lexical_cast<T>(to_str<CharT>(0)+to_str<CharT>(0)+to_str<CharT>(0)+s), max_val);
}
for (int i =1; i <=256; ++i) {
BOOST_CHECK_THROW(lexical_cast<T>( to_str<CharT>(i)+s ), bad_lexical_cast);
}
typedef BOOST_DEDUCED_TYPENAME boost::integral_promotion<T>::type promoted;
if ( !(boost::is_same<T, promoted>::value) )
{
promoted prom = max_val;
s = to_str<CharT>(max_val);
for (int i =1; i <=256; ++i) {
BOOST_CHECK_THROW(lexical_cast<T>( to_str<CharT>(prom+i) ), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>( to_str<CharT>(i)+s ), bad_lexical_cast);
}
}
}
if(limits::digits <= 16 && lcast_test_small_integral_types_completely)
// min and max have already been tested.
for(T t = 1 + min_val; t != max_val; ++t)
BOOST_CHECK(lexical_cast<T>(to_str<CharT>(t)) == t);
else
{
T const half_max_val = max_val / 2;
T const cnt = lcast_integral_test_counter; // to supress warnings
unsigned int const counter = cnt < half_max_val ? cnt : half_max_val;
T t;
unsigned int i;
// Test values around min:
t = min_val;
for(i = 0; i < counter; ++i, ++t)
BOOST_CHECK(lexical_cast<T>(to_str<CharT>(t)) == t);
// Test values around max:
t = max_val;
for(i = 0; i < counter; ++i, --t)
BOOST_CHECK(lexical_cast<T>(to_str<CharT>(t)) == t);
// Test values around zero:
if(limits::is_signed)
for(t = static_cast<T>(-counter); t < static_cast<T>(counter); ++t)
BOOST_CHECK(lexical_cast<T>(to_str<CharT>(t)) == t);
// Test values around 100, 1000, 10000, ...
T ten_power = 100;
for(int e = 2; e <= limits::digits10; ++e, ten_power *= 10)
{
// ten_power + 100 probably never overflows
for(t = ten_power - 100; t != ten_power + 100; ++t)
BOOST_CHECK(lexical_cast<T>(to_str<CharT>(t)) == t);
}
}
}
template<class T>
void test_conversion_from_to_integral_for_locale()
{
std::locale current_locale;
typedef std::numpunct<char> numpunct;
numpunct const& np = BOOST_USE_FACET(numpunct, current_locale);
if ( !np.grouping().empty() )
{
BOOST_CHECK_THROW(
lexical_cast<T>( std::string("100") + np.thousands_sep() + np.thousands_sep() + "0" )
, bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>( std::string("100") + np.thousands_sep() ), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>( np.thousands_sep() + std::string("100") ), bad_lexical_cast);
// Exception must not be thrown, when we are using no separators at all
BOOST_CHECK( lexical_cast<T>("30000") == static_cast<T>(30000) );
}
test_conversion_from_integral_to_integral<T>();
test_conversion_from_integral_to_string<T>('0');
test_conversion_from_string_to_integral<T>('0');
#if !defined(BOOST_LCAST_NO_WCHAR_T)
test_conversion_from_integral_to_string<T>(L'0');
test_conversion_from_string_to_integral<T>(L'0');
#endif
}
struct restore_oldloc
{
std::locale oldloc;
~restore_oldloc() { std::locale::global(oldloc); }
};
template<class T>
void test_conversion_from_to_integral()
{
char const zero = '0';
signed char const szero = '0';
unsigned char const uzero = '0';
test_conversion_from_integral_to_char<T>(zero);
test_conversion_from_char_to_integral<T>(zero);
test_conversion_from_integral_to_char<T>(szero);
test_conversion_from_char_to_integral<T>(szero);
test_conversion_from_integral_to_char<T>(uzero);
test_conversion_from_char_to_integral<T>(uzero);
#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T)
wchar_t const wzero = L'0';
test_conversion_from_integral_to_char<T>(wzero);
test_conversion_from_char_to_integral<T>(wzero);
#endif
#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
#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);
#endif
BOOST_CHECK(lexical_cast<T>("-1") == static_cast<T>(-1));
BOOST_CHECK(lexical_cast<T>("-9") == static_cast<T>(-9));
BOOST_CHECK(lexical_cast<T>(-1) == static_cast<T>(-1));
BOOST_CHECK(lexical_cast<T>(-9) == static_cast<T>(-9));
BOOST_CHECK_THROW(lexical_cast<T>("-1.0"), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>("-9.0"), bad_lexical_cast);
BOOST_CHECK(lexical_cast<T>(-1.0) == static_cast<T>(-1));
BOOST_CHECK(lexical_cast<T>(-9.0) == static_cast<T>(-9));
BOOST_CHECK(lexical_cast<T>(static_cast<T>(1)) == static_cast<T>(1));
BOOST_CHECK(lexical_cast<T>(static_cast<T>(9)) == static_cast<T>(9));
BOOST_CHECK_THROW(lexical_cast<T>(1.1f), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>(1.1), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>(1.1L), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>(1.0001f), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>(1.0001), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>(1.0001L), bad_lexical_cast);
BOOST_CHECK(lexical_cast<T>("+1") == static_cast<T>(1) );
BOOST_CHECK(lexical_cast<T>("+9") == static_cast<T>(9) );
BOOST_CHECK(lexical_cast<T>("+10") == static_cast<T>(10) );
BOOST_CHECK(lexical_cast<T>("+90") == static_cast<T>(90) );
BOOST_CHECK_THROW(lexical_cast<T>("++1"), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>("-+9"), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>("--1"), bad_lexical_cast);
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;
std::locale const& oldloc = guard.oldloc;
std::string grouping1 = BOOST_USE_FACET(numpunct, oldloc).grouping();
std::string grouping2(grouping1);
test_conversion_from_to_integral_for_locale<T>();
try
{
std::locale newloc("");
std::locale::global(newloc);
grouping2 = BOOST_USE_FACET(numpunct, newloc).grouping();
}
catch(std::exception const& ex)
{
std::string msg("Failed to set system locale: ");
msg += ex.what();
BOOST_TEST_MESSAGE(msg);
}
if(grouping1 != grouping2)
test_conversion_from_to_integral_for_locale<T>();
if(grouping1.empty() && grouping2.empty())
BOOST_TEST_MESSAGE("Formatting with thousands_sep has not been tested");
}
void test_conversion_from_to_short()
{
test_conversion_from_to_integral<short>();
}
void test_conversion_from_to_ushort()
{
test_conversion_from_to_integral<unsigned short>();
}
void test_conversion_from_to_int()
{
test_conversion_from_to_integral<int>();
}
void test_conversion_from_to_uint()
{
test_conversion_from_to_integral<unsigned int>();
}
void test_conversion_from_to_long()
{
test_conversion_from_to_integral<long>();
}
void test_conversion_from_to_ulong()
{
test_conversion_from_to_integral<unsigned long>();
}
void test_conversion_from_to_intmax_t()
{
test_conversion_from_to_integral<boost::intmax_t>();
}
void test_conversion_from_to_uintmax_t()
{
test_conversion_from_to_integral<boost::uintmax_t>();
}
#if defined(BOOST_HAS_LONG_LONG)
void test_conversion_from_to_longlong()
{
test_conversion_from_to_integral<boost::long_long_type>();
}
void test_conversion_from_to_ulonglong()
{
test_conversion_from_to_integral<boost::ulong_long_type>();
}
#elif defined(BOOST_HAS_MS_INT64)
void test_conversion_from_to_longlong()
{
test_conversion_from_to_integral<__int64>();
}
void test_conversion_from_to_ulonglong()
{
test_conversion_from_to_integral<unsigned __int64>();
}
#endif
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
void test_traits()
{
@@ -476,11 +928,6 @@ void test_wtraits()
void test_allocator()
{
// Following test cause compilation error on MSVC2012:
// (Reason: cannot convert from 'std::_Wrap_alloc<_Alloc>' to 'const my_allocator<CharT>')
//
// MSVC developer is notified about this issue
#if !defined(_MSC_VER) || (_MSC_VER < 1700)
typedef std::basic_string< char
, std::char_traits<char>
, my_allocator<char>
@@ -493,16 +940,10 @@ void test_allocator()
BOOST_CHECK(boost::lexical_cast<my_string>(1) == "1");
BOOST_CHECK(boost::lexical_cast<my_string>("s") == s);
BOOST_CHECK(boost::lexical_cast<my_string>(std::string("s")) == s);
#endif
}
void test_wallocator()
{
// Following test cause compilation error on MSVC2012:
// (Reason: cannot convert from 'std::_Wrap_alloc<_Alloc>' to 'const my_allocator<CharT>')
//
// MSVC developer is notified about this issue
#if !defined(_MSC_VER) || (_MSC_VER < 1700)
typedef std::basic_string< wchar_t
, std::char_traits<wchar_t>
, my_allocator<wchar_t>
@@ -515,12 +956,10 @@ void test_wallocator()
BOOST_CHECK(boost::lexical_cast<my_string>(1) == L"1");
BOOST_CHECK(boost::lexical_cast<my_string>(L"s") == s);
BOOST_CHECK(boost::lexical_cast<my_string>(std::wstring(L"s")) == s);
#endif
}
#endif
void test_char_types_conversions()
{
const char c_arr[] = "Test array of chars";
@@ -601,17 +1040,3 @@ void test_char32_conversions()
}
#endif
template <class To, class From, class Func>
To try_cast_by_ptr(const From& from, const Func& f) {
return f(from);
};
void test_getting_pointer_to_function()
{
// Just checking that &lexical_cast<To, From> is not ambiguous
BOOST_CHECK_EQUAL(100, try_cast_by_ptr<int>("100", &boost::lexical_cast<int, const char[4]>));
BOOST_CHECK_EQUAL(100, try_cast_by_ptr<int>("100", &boost::lexical_cast<int, std::string>));
BOOST_CHECK_EQUAL(std::string("100"), try_cast_by_ptr<std::string>(100, &boost::lexical_cast<std::string, int>));
}
+1 -2
View File
@@ -28,7 +28,7 @@ using namespace boost;
using std::cout;
int test_main( int , char * [] )
int test_main( int argc, char * argv[] )
{
# ifdef NDEBUG
@@ -96,6 +96,5 @@ int test_main( int , char * [] )
{ cout<<"caught bad_numeric_cast #5\n"; caught_exception = true; }
BOOST_CHECK ( caught_exception );
(void)ul; // Supressing GCC warning about set but unused wariable
return 0 ;
}
+1 -46
View File
@@ -13,7 +13,6 @@
#define BOOST_CHRONO_HEADER_ONLY
#include <boost/lexical_cast.hpp>
#include <boost/chrono.hpp>
#include <fstream>
#include <cstring>
@@ -22,13 +21,6 @@
// File to output data
std::fstream fout;
namespace boost {
inline std::istream& operator>> (std::istream& in, boost::array<char,50>& res) {
in >> res.begin();
return in;
}
}
template <class OutT, class InT>
static inline void test_lexical(const InT& in_val) {
OutT out_val = boost::lexical_cast<OutT>(in_val);
@@ -45,28 +37,6 @@ static inline void test_ss_constr(const InT& in_val) {
if (ss.fail()) throw std::logic_error("descr");
}
template <class OutT, class CharT, std::size_t N>
static inline void test_ss_constr(const boost::array<CharT, N>& in_val) {
OutT out_val;
std::stringstream ss;
ss << in_val.begin();
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 CharT, std::size_t N>
static inline void test_ss_noconstr(StringStreamT& ss, const boost::array<CharT, N>& in_val) {
OutT out_val;
ss << in_val.begin(); // 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();
}
template <class OutT, class StringStreamT, class InT>
static inline void test_ss_noconstr(StringStreamT& ss, const InT& in_val) {
OutT out_val;
@@ -94,12 +64,6 @@ struct structure_sprintf {
};
struct structure_sscanf {
template <class OutT, class BufferT, class CharT, std::size_t N>
static inline void test(BufferT* /*buffer*/, const boost::array<CharT, N>& in_val, const char* const conv) {
OutT out_val;
sscanf(in_val.cbegin(), conv, &out_val);
}
template <class OutT, class BufferT, class InT>
static inline void test(BufferT* /*buffer*/, const InT& in_val, const char* const conv) {
OutT out_val;
@@ -265,7 +229,7 @@ void string_like_test_set(const std::string& from) {
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<boost::array<char, 50>, ssc_t>(from + "->array<char, 50>", conv("1.123"), "%s");
perf_test<std::string, structure_fake>(from + "->string", conv("string"), "%Lf");
perf_test<boost::container::string, structure_fake>(from + "->container::string"
@@ -304,14 +268,6 @@ struct to_iterator_range {
}
};
struct to_array_50 {
boost::array<char, 50> operator()(const char* const c) const {
boost::array<char, 50> ret;
std::strcpy(ret.begin(), c);
return ret;
}
};
int main(int argc, char** argv) {
BOOST_ASSERT(argc >= 2);
std::string output_path(argv[1]);
@@ -354,7 +310,6 @@ int main(int argc, char** argv) {
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*>");
string_like_test_set<to_array_50>("array<char, 50>");
perf_test<int, structure_fake>("int->int", 100, "");
perf_test<double, structure_fake>("float->double", 100.0f, "");
-2
View File
@@ -47,7 +47,5 @@ test-suite conversion
<toolset>gcc-4.7:<cflags>-fno-exceptions
]
[ run lexical_cast_iterator_range_test.cpp ]
[ run lexical_cast_arrays_test.cpp ]
[ run lexical_cast_integral_types_test.cpp ]
;
+1 -1
View File
@@ -28,7 +28,7 @@ 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;
-2
View File
@@ -19,6 +19,4 @@ struct foo
int test_main(int, char*[])
{
foo x = implicit_cast<foo>("foobar");
(void)x; // warning suppression.
return 0;
}
-367
View File
@@ -1,367 +0,0 @@
// Testing boost::lexical_cast with boost::container::string.
//
// 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/lexical_cast.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/array.hpp>
void testing_boost_array_output_conversion();
void testing_std_array_output_conversion();
void testing_boost_array_input_conversion();
void testing_std_array_input_conversion();
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::array and std::array");
suite->add(BOOST_TEST_CASE(testing_boost_array_output_conversion));
suite->add(BOOST_TEST_CASE(testing_std_array_output_conversion));
suite->add(BOOST_TEST_CASE(testing_boost_array_input_conversion));
suite->add(BOOST_TEST_CASE(testing_std_array_input_conversion));
return suite;
}
template <template <class, std::size_t> class ArrayT, class T>
static void testing_template_array_output_on_spec_value(T val)
{
typedef ArrayT<char, 300> arr_type;
typedef ArrayT<char, 1> short_arr_type;
typedef ArrayT<unsigned char, 300> uarr_type;
typedef ArrayT<unsigned char, 1> ushort_arr_type;
typedef ArrayT<signed char, 4> sarr_type;
typedef ArrayT<signed char, 3> sshort_arr_type;
std::string ethalon("100");
using namespace std;
{
arr_type res1 = lexical_cast<arr_type>(val);
BOOST_CHECK_EQUAL(res1.begin(), ethalon);
const arr_type res2 = lexical_cast<arr_type>(val);
BOOST_CHECK_EQUAL(res2.begin(), ethalon);
BOOST_CHECK_THROW(lexical_cast<short_arr_type>(val), boost::bad_lexical_cast);
}
{
uarr_type res1 = lexical_cast<uarr_type>(val);
BOOST_CHECK_EQUAL(reinterpret_cast<char*>(res1.begin()), ethalon);
const uarr_type res2 = lexical_cast<uarr_type>(val);
BOOST_CHECK_EQUAL(reinterpret_cast<const char*>(res2.begin()), ethalon);
BOOST_CHECK_THROW(lexical_cast<ushort_arr_type>(val), boost::bad_lexical_cast);
}
{
sarr_type res1 = lexical_cast<sarr_type>(val);
BOOST_CHECK_EQUAL(reinterpret_cast<char*>(res1.begin()), ethalon);
const sarr_type res2 = lexical_cast<sarr_type>(val);
BOOST_CHECK_EQUAL(reinterpret_cast<const char*>(res2.begin()), ethalon);
BOOST_CHECK_THROW(lexical_cast<sshort_arr_type>(val), boost::bad_lexical_cast);
}
#if !defined(BOOST_NO_STRINGSTREAM) && !defined(BOOST_NO_STD_WSTRING)
typedef ArrayT<wchar_t, 300> warr_type;
typedef ArrayT<wchar_t, 3> wshort_arr_type;
std::wstring wethalon(L"100");
{
warr_type res = lexical_cast<warr_type>(val);
BOOST_CHECK(res.begin() == wethalon);
}
{
const warr_type res = lexical_cast<warr_type>(val);
BOOST_CHECK(res.begin() == wethalon);
}
BOOST_CHECK_THROW(lexical_cast<wshort_arr_type>(val), boost::bad_lexical_cast);
#endif
#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS)
typedef ArrayT<char16_t, 300> u16arr_type;
typedef ArrayT<char16_t, 3> u16short_arr_type;
std::u16string u16ethalon(u"100");
{
u16arr_type res = lexical_cast<u16arr_type>(val);
BOOST_CHECK(res.begin() == u16ethalon);
}
{
const u16arr_type res = lexical_cast<u16arr_type>(val);
BOOST_CHECK(res.begin() == u16ethalon);
}
BOOST_CHECK_THROW(lexical_cast<u16short_arr_type>(val), boost::bad_lexical_cast);
#endif
#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS)
typedef ArrayT<char32_t, 300> u32arr_type;
typedef ArrayT<char32_t, 3> u32short_arr_type;
std::u32string u32ethalon(U"100");
{
u32arr_type res = lexical_cast<u32arr_type>(val);
BOOST_CHECK(res.begin() == u32ethalon);
}
{
const u32arr_type res = lexical_cast<u32arr_type>(val);
BOOST_CHECK(res.begin() == u32ethalon);
}
BOOST_CHECK_THROW(lexical_cast<u32short_arr_type>(val), boost::bad_lexical_cast);
#endif
}
template <template <class, std::size_t> class ArrayT>
static void testing_template_array_output_on_char_value()
{
typedef ArrayT<char, 300> arr_type;
typedef ArrayT<char, 1> short_arr_type;
typedef ArrayT<unsigned char, 300> uarr_type;
typedef ArrayT<unsigned char, 1> ushort_arr_type;
typedef ArrayT<signed char, 4> sarr_type;
typedef ArrayT<signed char, 3> sshort_arr_type;
const char val[] = "100";
std::string ethalon("100");
using namespace std;
{
arr_type res1 = lexical_cast<arr_type>(val);
BOOST_CHECK_EQUAL(res1.begin(), ethalon);
const arr_type res2 = lexical_cast<arr_type>(val);
BOOST_CHECK_EQUAL(res2.begin(), ethalon);
BOOST_CHECK_THROW(lexical_cast<short_arr_type>(val), boost::bad_lexical_cast);
}
{
uarr_type res1 = lexical_cast<uarr_type>(val);
BOOST_CHECK_EQUAL(reinterpret_cast<char*>(res1.begin()), ethalon);
const uarr_type res2 = lexical_cast<uarr_type>(val);
BOOST_CHECK_EQUAL(reinterpret_cast<const char*>(res2.begin()), ethalon);
BOOST_CHECK_THROW(lexical_cast<ushort_arr_type>(val), boost::bad_lexical_cast);
}
{
sarr_type res1 = lexical_cast<sarr_type>(val);
BOOST_CHECK_EQUAL(reinterpret_cast<char*>(res1.begin()), ethalon);
const sarr_type res2 = lexical_cast<sarr_type>(val);
BOOST_CHECK_EQUAL(reinterpret_cast<const char*>(res2.begin()), ethalon);
BOOST_CHECK_THROW(lexical_cast<sshort_arr_type>(val), boost::bad_lexical_cast);
}
#if !defined(BOOST_NO_STRINGSTREAM) && !defined(BOOST_NO_STD_WSTRING)
typedef ArrayT<wchar_t, 4> warr_type;
typedef ArrayT<wchar_t, 3> wshort_arr_type;
std::wstring wethalon(L"100");
{
warr_type res = lexical_cast<warr_type>(val);
BOOST_CHECK(res.begin() == wethalon);
warr_type res3 = lexical_cast<warr_type>(wethalon);
BOOST_CHECK(res3.begin() == wethalon);
}
{
const warr_type res = lexical_cast<warr_type>(val);
BOOST_CHECK(res.begin() == wethalon);
const warr_type res3 = lexical_cast<warr_type>(wethalon);
BOOST_CHECK(res3.begin() == wethalon);
}
BOOST_CHECK_THROW(lexical_cast<wshort_arr_type>(val), boost::bad_lexical_cast);
#endif
#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS)
typedef ArrayT<char16_t, 300> u16arr_type;
typedef ArrayT<char16_t, 3> u16short_arr_type;
std::u16string u16ethalon(u"100");
{
#ifdef BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES
u16arr_type res = lexical_cast<u16arr_type>(val);
BOOST_CHECK(res.begin() == u16ethalon);
#endif
u16arr_type res3 = lexical_cast<u16arr_type>(u16ethalon);
BOOST_CHECK(res3.begin() == u16ethalon);
}
{
#ifdef BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES
const u16arr_type res = lexical_cast<u16arr_type>(val);
BOOST_CHECK(res.begin() == u16ethalon);
#endif
const u16arr_type res3 = lexical_cast<u16arr_type>(u16ethalon);
BOOST_CHECK(res3.begin() == u16ethalon);
}
BOOST_CHECK_THROW(lexical_cast<u16short_arr_type>(val), boost::bad_lexical_cast);
#endif
#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS)
typedef ArrayT<char32_t, 300> u32arr_type;
typedef ArrayT<char32_t, 3> u32short_arr_type;
std::u32string u32ethalon(U"100");
{
#ifdef BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES
u32arr_type res = lexical_cast<u32arr_type>(val);
BOOST_CHECK(res.begin() == u32ethalon);
#endif
u32arr_type res3 = lexical_cast<u32arr_type>(u32ethalon);
BOOST_CHECK(res3.begin() == u32ethalon);
}
{
#ifdef BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES
const u32arr_type res = lexical_cast<u32arr_type>(val);
BOOST_CHECK(res.begin() == u32ethalon);
#endif
const u32arr_type res3 = lexical_cast<u32arr_type>(u32ethalon);
BOOST_CHECK(res3.begin() == u32ethalon);
}
BOOST_CHECK_THROW(lexical_cast<u32short_arr_type>(val), boost::bad_lexical_cast);
#endif
}
void testing_boost_array_output_conversion()
{
testing_template_array_output_on_char_value<boost::array>();
testing_template_array_output_on_spec_value<boost::array>(100);
testing_template_array_output_on_spec_value<boost::array>(static_cast<short>(100));
testing_template_array_output_on_spec_value<boost::array>(static_cast<unsigned short>(100));
testing_template_array_output_on_spec_value<boost::array>(static_cast<unsigned int>(100));
}
void testing_std_array_output_conversion()
{
#if !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
testing_template_array_output_on_char_value<std::array>();
testing_template_array_output_on_spec_value<std::array>(100);
testing_template_array_output_on_spec_value<std::array>(static_cast<short>(100));
testing_template_array_output_on_spec_value<std::array>(static_cast<unsigned short>(100));
testing_template_array_output_on_spec_value<std::array>(static_cast<unsigned int>(100));
#endif
BOOST_CHECK(true);
}
template <template <class, std::size_t> class ArrayT>
static void testing_generic_array_input_conversion()
{
{
ArrayT<char, 4> var_zero_terminated = {{ '1', '0', '0', '\0'}};
BOOST_CHECK_EQUAL(lexical_cast<std::string>(var_zero_terminated), "100");
BOOST_CHECK_EQUAL(lexical_cast<int>(var_zero_terminated), 100);
ArrayT<char, 3> var_none_terminated = {{ '1', '0', '0'}};
BOOST_CHECK_EQUAL(lexical_cast<std::string>(var_none_terminated), "100");
BOOST_CHECK_EQUAL(lexical_cast<short>(var_none_terminated), static_cast<short>(100));
ArrayT<const char, 4> var_zero_terminated_const_char = {{ '1', '0', '0', '\0'}};
BOOST_CHECK_EQUAL(lexical_cast<std::string>(var_zero_terminated_const_char), "100");
ArrayT<const char, 3> var_none_terminated_const_char = {{ '1', '0', '0'}};
BOOST_CHECK_EQUAL(lexical_cast<std::string>(var_none_terminated_const_char), "100");
const ArrayT<char, 4> var_zero_terminated_const_var = {{ '1', '0', '0', '\0'}};
BOOST_CHECK_EQUAL(lexical_cast<std::string>(var_zero_terminated_const_var), "100");
const ArrayT<char, 3> var_none_terminated_const_var = {{ '1', '0', '0'}};
BOOST_CHECK_EQUAL(lexical_cast<std::string>(var_none_terminated_const_var), "100");
const ArrayT<const char, 4> var_zero_terminated_const_var_const_char = {{ '1', '0', '0', '\0'}};
BOOST_CHECK_EQUAL(lexical_cast<std::string>(var_zero_terminated_const_var_const_char), "100");
const ArrayT<const char, 3> var_none_terminated_const_var_const_char = {{ '1', '0', '0'}};
BOOST_CHECK_EQUAL(lexical_cast<std::string>(var_none_terminated_const_var_const_char), "100");
BOOST_CHECK_EQUAL(lexical_cast<int>(var_none_terminated_const_var_const_char), 100);
}
{
const ArrayT<const unsigned char, 4> var_zero_terminated_const_var_const_char = {{ '1', '0', '0', '\0'}};
BOOST_CHECK_EQUAL(lexical_cast<std::string>(var_zero_terminated_const_var_const_char), "100");
const ArrayT<const unsigned char, 3> var_none_terminated_const_var_const_char = {{ '1', '0', '0'}};
BOOST_CHECK_EQUAL(lexical_cast<std::string>(var_none_terminated_const_var_const_char), "100");
}
{
const ArrayT<const signed char, 4> var_zero_terminated_const_var_const_char = {{ '1', '0', '0', '\0'}};
BOOST_CHECK_EQUAL(lexical_cast<std::string>(var_zero_terminated_const_var_const_char), "100");
const ArrayT<const signed char, 3> var_none_terminated_const_var_const_char = {{ '1', '0', '0'}};
BOOST_CHECK_EQUAL(lexical_cast<std::string>(var_none_terminated_const_var_const_char), "100");
BOOST_CHECK_EQUAL(lexical_cast<unsigned int>(var_none_terminated_const_var_const_char), 100u);
}
#if !defined(BOOST_NO_STRINGSTREAM) && !defined(BOOST_NO_STD_WSTRING)
{
const ArrayT<const wchar_t, 4> var_zero_terminated_const_var_const_char = {{ L'1', L'0', L'0', L'\0'}};
BOOST_CHECK(lexical_cast<std::wstring>(var_zero_terminated_const_var_const_char) == L"100");
const ArrayT<const wchar_t, 3> var_none_terminated_const_var_const_char = {{ L'1', L'0', L'0'}};
BOOST_CHECK(lexical_cast<std::wstring>(var_none_terminated_const_var_const_char) == L"100");
BOOST_CHECK_EQUAL(lexical_cast<int>(var_none_terminated_const_var_const_char), 100);
}
#endif
#if !defined(BOOST_NO_CHAR16_T) && !defined(BOOST_NO_UNICODE_LITERALS)
{
const ArrayT<const char16_t, 4> var_zero_terminated_const_var_const_char = {{ u'1', u'0', u'0', u'\0'}};
BOOST_CHECK(lexical_cast<std::u16string>(var_zero_terminated_const_var_const_char) == u"100");
BOOST_CHECK_EQUAL(lexical_cast<unsigned short>(var_zero_terminated_const_var_const_char), static_cast<unsigned short>(100));
const ArrayT<const char16_t, 3> var_none_terminated_const_var_const_char = {{ u'1', u'0', u'0'}};
BOOST_CHECK(lexical_cast<std::u16string>(var_none_terminated_const_var_const_char) == u"100");
}
#endif
#if !defined(BOOST_NO_CHAR32_T) && !defined(BOOST_NO_UNICODE_LITERALS)
{
const ArrayT<const char32_t, 4> var_zero_terminated_const_var_const_char = {{ U'1', U'0', U'0', U'\0'}};
BOOST_CHECK(lexical_cast<std::u32string>(var_zero_terminated_const_var_const_char) == U"100");
const ArrayT<const char32_t, 3> var_none_terminated_const_var_const_char = {{ U'1', U'0', U'0'}};
BOOST_CHECK(lexical_cast<std::u32string>(var_none_terminated_const_var_const_char) == U"100");
BOOST_CHECK_EQUAL(lexical_cast<int>(var_none_terminated_const_var_const_char), 100);
}
#endif
}
void testing_boost_array_input_conversion()
{
testing_generic_array_input_conversion<boost::array>();
}
void testing_std_array_input_conversion()
{
#if !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY)
testing_generic_array_input_conversion<std::array>();
#endif
BOOST_CHECK(true);
}
+7 -8
View File
@@ -105,13 +105,13 @@ void test_conversion_from_to_float_for_locale()
/*
* Converts char* [and wchar_t*] to float number type and checks, that generated
* number does not exceeds allowed epsilon.
* Converts char* [and wchar_t] to float number type and checks, that generated
* number is in interval [base_value-epsilon, base_value+epsilon].
*/
#ifndef BOOST_LCAST_NO_WCHAR_T
#define CHECK_CLOSE_ABS_DIFF(VAL,PREFIX) \
converted_val = lexical_cast<test_t>(#VAL); \
BOOST_CHECK_CLOSE_FRACTION( (VAL ## L? VAL ## L : std::numeric_limits<test_t>::epsilon()), \
BOOST_CHECK_CLOSE_FRACTION( (VAL ## L? VAL ## L : std::numeric_limits<test_t>::epsilon()), \
(converted_val ? converted_val : std::numeric_limits<test_t>::epsilon()), \
std::numeric_limits<test_t>::epsilon() \
); \
@@ -120,7 +120,7 @@ void test_conversion_from_to_float_for_locale()
#else
#define CHECK_CLOSE_ABS_DIFF(VAL,TYPE) \
converted_val = lexical_cast<test_t>(#VAL); \
BOOST_CHECK_CLOSE_FRACTION( (VAL ## L? VAL ## L : std::numeric_limits<test_t>::epsilon()), \
BOOST_CHECK_CLOSE_FRACTION( (VAL ## L? VAL ## L : std::numeric_limits<test_t>::epsilon()), \
(converted_val ? converted_val : std::numeric_limits<test_t>::epsilon()), \
std::numeric_limits<test_t>::epsilon() \
);
@@ -287,7 +287,7 @@ void test_float_typess_for_overflows()
test_t minvalue = (std::numeric_limits<test_t>::min)();
std::string s_min_value = lexical_cast<std::string>(minvalue);
BOOST_CHECK_CLOSE_FRACTION(minvalue, lexical_cast<test_t>(minvalue), (std::numeric_limits<test_t>::epsilon()));
BOOST_CHECK_CLOSE_FRACTION(minvalue, lexical_cast<test_t>(s_min_value), (std::numeric_limits<test_t>::epsilon() * 2));
BOOST_CHECK_CLOSE_FRACTION(minvalue, lexical_cast<test_t>(s_min_value), (std::numeric_limits<test_t>::epsilon()));
test_t maxvalue = (std::numeric_limits<test_t>::max)();
std::string s_max_value = lexical_cast<std::string>(maxvalue);
@@ -326,14 +326,13 @@ void test_float_typess_for_overflows()
#undef CHECK_CLOSE_ABS_DIFF
// Epsilon is multiplied by 2 because of two lexical conversions
#define TEST_TO_FROM_CAST_AROUND_TYPED(VAL,STRING_TYPE) \
test_value = VAL + std::numeric_limits<test_t>::epsilon() * i ; \
converted_val = lexical_cast<test_t>( lexical_cast<STRING_TYPE>(test_value) ); \
BOOST_CHECK_CLOSE_FRACTION( \
BOOST_CHECK_CLOSE_FRACTION( \
test_value, \
converted_val, \
std::numeric_limits<test_t>::epsilon() * 2 \
std::numeric_limits<test_t>::epsilon() \
);
/*
-539
View File
@@ -1,539 +0,0 @@
// Unit test for boost::lexical_cast.
//
// See http://www.boost.org for most recent version, including documentation.
//
// Copyright Terje Sletteb and Kevlin Henney, 2005.
// Copyright Alexander Nasonov, 2006.
// Copyright Antony Polukhin, 2011-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).
//
// Note: The unit test no longer compile on MSVC 6, but lexical_cast itself works for it.
//
// We need this #define before any #includes: otherwise msvc will emit warnings
// deep within std::string, resulting from our (perfectly legal) use of basic_string
// with a custom traits class:
//
#define _SCL_SECURE_NO_WARNINGS
#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/cstdint.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/test/floating_point_comparison.hpp>
#include <boost/type_traits/integral_promotion.hpp>
#include <string>
#include <vector>
#include <memory>
#if (defined(BOOST_HAS_LONG_LONG) || defined(BOOST_HAS_MS_INT64)) \
&& !(defined(BOOST_MSVC) && BOOST_MSVC < 1300)
#define LCAST_TEST_LONGLONG
#endif
#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING)
#define BOOST_LCAST_NO_WCHAR_T
#endif
// Test all 65536 values if true:
bool const lcast_test_small_integral_types_completely = false;
// lcast_integral_test_counter: use when testing all values of an integral
// types is not possible. Max. portable value is 32767.
int const lcast_integral_test_counter=500;
using namespace boost;
void test_conversion_from_to_short();
void test_conversion_from_to_ushort();
void test_conversion_from_to_int();
void test_conversion_from_to_uint();
void test_conversion_from_to_long();
void test_conversion_from_to_ulong();
void test_conversion_from_to_intmax_t();
void test_conversion_from_to_uintmax_t();
#ifdef LCAST_TEST_LONGLONG
void test_conversion_from_to_longlong();
void test_conversion_from_to_ulonglong();
#endif
unit_test::test_suite *init_unit_test_suite(int, char *[])
{
unit_test::test_suite *suite =
BOOST_TEST_SUITE("lexical_cast unit test on integral types");
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_short));
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ushort));
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_int));
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_uint));
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_long));
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ulong));
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_intmax_t));
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_uintmax_t));
#ifdef LCAST_TEST_LONGLONG
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_longlong));
suite->add(BOOST_TEST_CASE(&test_conversion_from_to_ulonglong));
#endif
return suite;
}
template<class T, class CharT>
void test_conversion_from_integral_to_char(CharT zero)
{
BOOST_CHECK(lexical_cast<CharT>(static_cast<T>(0)) == zero + 0);
BOOST_CHECK(lexical_cast<CharT>(static_cast<T>(1)) == zero + 1);
BOOST_CHECK(lexical_cast<CharT>(static_cast<T>(2)) == zero + 2);
BOOST_CHECK(lexical_cast<CharT>(static_cast<T>(3)) == zero + 3);
BOOST_CHECK(lexical_cast<CharT>(static_cast<T>(4)) == zero + 4);
BOOST_CHECK(lexical_cast<CharT>(static_cast<T>(5)) == zero + 5);
BOOST_CHECK(lexical_cast<CharT>(static_cast<T>(6)) == zero + 6);
BOOST_CHECK(lexical_cast<CharT>(static_cast<T>(7)) == zero + 7);
BOOST_CHECK(lexical_cast<CharT>(static_cast<T>(8)) == zero + 8);
BOOST_CHECK(lexical_cast<CharT>(static_cast<T>(9)) == zero + 9);
BOOST_CHECK_THROW(lexical_cast<CharT>(static_cast<T>(10)), bad_lexical_cast);
T t = (std::numeric_limits<T>::max)();
BOOST_CHECK_THROW(lexical_cast<CharT>(t), bad_lexical_cast);
}
template<class T, class CharT>
void test_conversion_from_char_to_integral(CharT zero)
{
BOOST_CHECK(lexical_cast<T>( static_cast<CharT>(zero + 0)) == static_cast<T>(0) );
BOOST_CHECK(lexical_cast<T>( static_cast<CharT>(zero + 1)) == static_cast<T>(1) );
BOOST_CHECK(lexical_cast<T>( static_cast<CharT>(zero + 2)) == static_cast<T>(2) );
BOOST_CHECK(lexical_cast<T>( static_cast<CharT>(zero + 3)) == static_cast<T>(3) );
BOOST_CHECK(lexical_cast<T>( static_cast<CharT>(zero + 4)) == static_cast<T>(4) );
BOOST_CHECK(lexical_cast<T>( static_cast<CharT>(zero + 5)) == static_cast<T>(5) );
BOOST_CHECK(lexical_cast<T>( static_cast<CharT>(zero + 6)) == static_cast<T>(6) );
BOOST_CHECK(lexical_cast<T>( static_cast<CharT>(zero + 7)) == static_cast<T>(7) );
BOOST_CHECK(lexical_cast<T>( static_cast<CharT>(zero + 8)) == static_cast<T>(8) );
BOOST_CHECK(lexical_cast<T>( static_cast<CharT>(zero + 9)) == static_cast<T>(9) );
BOOST_CHECK_THROW(lexical_cast<T>( static_cast<CharT>(zero + 10)), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>( static_cast<CharT>(zero - 1)), bad_lexical_cast);
}
template<class T>
void test_conversion_from_integral_to_integral()
{
T t = 0;
BOOST_CHECK(lexical_cast<T>(t) == t);
// Next two variables are used to supress warnings.
int st = 32767; unsigned int ut = st;
t = st;
BOOST_CHECK(lexical_cast<short>(t) == st);
BOOST_CHECK(lexical_cast<unsigned short>(t) == ut);
BOOST_CHECK(lexical_cast<int>(t) == st);
BOOST_CHECK(lexical_cast<unsigned int>(t) == ut);
BOOST_CHECK(lexical_cast<long>(t) == st);
BOOST_CHECK(lexical_cast<unsigned long>(t) == ut);
t = (std::numeric_limits<T>::max)();
BOOST_CHECK(lexical_cast<T>(t) == t);
t = (std::numeric_limits<T>::min)();
BOOST_CHECK(lexical_cast<T>(t) == t);
}
// Replace "-,999" with "-999".
template<class CharT>
std::basic_string<CharT> to_str_gcc_workaround(std::basic_string<CharT> str)
{
std::locale loc;
std::numpunct<CharT> const& np = BOOST_USE_FACET(std::numpunct<CharT>, loc);
std::ctype<CharT> const& ct = BOOST_USE_FACET(std::ctype<CharT>, loc);
if(np.grouping().empty())
return str;
CharT prefix[3] = { ct.widen('-'), np.thousands_sep(), CharT() };
if(str.find(prefix) != 0)
return str;
prefix[1] = CharT();
str.replace(0, 2, prefix);
return str;
}
template<class CharT, class T>
std::basic_string<CharT> to_str(T t)
{
std::basic_ostringstream<CharT> o;
o << t;
return to_str_gcc_workaround(o.str());
}
template<class T, class CharT>
void test_conversion_from_integral_to_string(CharT)
{
typedef std::numeric_limits<T> limits;
typedef std::basic_string<CharT> string_type;
T t;
t = (limits::min)();
BOOST_CHECK(lexical_cast<string_type>(t) == to_str<CharT>(t));
t = (limits::max)();
BOOST_CHECK(lexical_cast<string_type>(t) == to_str<CharT>(t));
if(limits::digits <= 16 && lcast_test_small_integral_types_completely)
// min and max have already been tested.
for(t = 1 + (limits::min)(); t != (limits::max)(); ++t)
BOOST_CHECK(lexical_cast<string_type>(t) == to_str<CharT>(t));
else
{
T const min_val = (limits::min)();
T const max_val = (limits::max)();
T const half_max_val = max_val / 2;
T const cnt = lcast_integral_test_counter; // to supress warnings
unsigned int const counter = cnt < half_max_val ? cnt : half_max_val;
unsigned int i;
// Test values around min:
t = min_val;
for(i = 0; i < counter; ++i, ++t)
BOOST_CHECK(lexical_cast<string_type>(t) == to_str<CharT>(t));
// Test values around max:
t = max_val;
for(i = 0; i < counter; ++i, --t)
BOOST_CHECK(lexical_cast<string_type>(t) == to_str<CharT>(t));
// Test values around zero:
if(limits::is_signed)
for(t = static_cast<T>(-counter); t < static_cast<T>(counter); ++t)
BOOST_CHECK(lexical_cast<string_type>(t) == to_str<CharT>(t));
// Test values around 100, 1000, 10000, ...
T ten_power = 100;
for(int e = 2; e <= limits::digits10; ++e, ten_power *= 10)
{
// ten_power + 100 probably never overflows
for(t = ten_power - 100; t != ten_power + 100; ++t)
BOOST_CHECK(lexical_cast<string_type>(t) == to_str<CharT>(t));
}
}
}
template<class T, class CharT>
void test_conversion_from_string_to_integral(CharT)
{
typedef std::numeric_limits<T> limits;
typedef std::basic_string<CharT> string_type;
string_type s;
string_type const zero = to_str<CharT>(0);
string_type const nine = to_str<CharT>(9);
T const min_val = (limits::min)();
T const max_val = (limits::max)();
s = to_str<CharT>(min_val);
BOOST_CHECK_EQUAL(lexical_cast<T>(s), min_val);
if(limits::is_signed)
{
BOOST_CHECK_THROW(lexical_cast<T>(s + zero), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>(s + nine), bad_lexical_cast);
}
s = to_str<CharT>(max_val);
BOOST_CHECK_EQUAL(lexical_cast<T>(s), max_val);
{
BOOST_CHECK_THROW(lexical_cast<T>(s + zero), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>(s + nine), bad_lexical_cast);
s = to_str<CharT>(max_val);
for (int i =1; i <=10; ++i) {
s[s.size()-1] += 1;
BOOST_CHECK_THROW(lexical_cast<T>( s ), bad_lexical_cast);
}
s = to_str<CharT>(max_val);
std::locale loc;
typedef std::numpunct<char> numpunct;
if ( BOOST_USE_FACET(numpunct, loc).grouping().empty() ) {
// Following tests work well for locale C
BOOST_CHECK_EQUAL(lexical_cast<T>(to_str<CharT>(0)+s), max_val);
BOOST_CHECK_EQUAL(lexical_cast<T>(to_str<CharT>(0)+to_str<CharT>(0)+s), max_val);
BOOST_CHECK_EQUAL(lexical_cast<T>(to_str<CharT>(0)+to_str<CharT>(0)+to_str<CharT>(0)+s), max_val);
}
for (int i =1; i <=256; ++i) {
BOOST_CHECK_THROW(lexical_cast<T>( to_str<CharT>(i)+s ), bad_lexical_cast);
}
typedef BOOST_DEDUCED_TYPENAME boost::integral_promotion<T>::type promoted;
if ( !(boost::is_same<T, promoted>::value) )
{
promoted prom = max_val;
s = to_str<CharT>(max_val);
for (int i =1; i <=256; ++i) {
BOOST_CHECK_THROW(lexical_cast<T>( to_str<CharT>(prom+i) ), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>( to_str<CharT>(i)+s ), bad_lexical_cast);
}
}
}
if(limits::digits <= 16 && lcast_test_small_integral_types_completely)
// min and max have already been tested.
for(T t = 1 + min_val; t != max_val; ++t)
BOOST_CHECK(lexical_cast<T>(to_str<CharT>(t)) == t);
else
{
T const half_max_val = max_val / 2;
T const cnt = lcast_integral_test_counter; // to supress warnings
unsigned int const counter = cnt < half_max_val ? cnt : half_max_val;
T t;
unsigned int i;
// Test values around min:
t = min_val;
for(i = 0; i < counter; ++i, ++t)
BOOST_CHECK(lexical_cast<T>(to_str<CharT>(t)) == t);
// Test values around max:
t = max_val;
for(i = 0; i < counter; ++i, --t)
BOOST_CHECK(lexical_cast<T>(to_str<CharT>(t)) == t);
// Test values around zero:
if(limits::is_signed)
for(t = static_cast<T>(-counter); t < static_cast<T>(counter); ++t)
BOOST_CHECK(lexical_cast<T>(to_str<CharT>(t)) == t);
// Test values around 100, 1000, 10000, ...
T ten_power = 100;
for(int e = 2; e <= limits::digits10; ++e, ten_power *= 10)
{
// ten_power + 100 probably never overflows
for(t = ten_power - 100; t != ten_power + 100; ++t)
BOOST_CHECK(lexical_cast<T>(to_str<CharT>(t)) == t);
}
}
}
template<class T>
void test_conversion_from_to_integral_for_locale()
{
std::locale current_locale;
typedef std::numpunct<char> numpunct;
numpunct const& np = BOOST_USE_FACET(numpunct, current_locale);
if ( !np.grouping().empty() )
{
BOOST_CHECK_THROW(
lexical_cast<T>( std::string("100") + np.thousands_sep() + np.thousands_sep() + "0" )
, bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>( std::string("100") + np.thousands_sep() ), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>( np.thousands_sep() + std::string("100") ), bad_lexical_cast);
// Exception must not be thrown, when we are using no separators at all
BOOST_CHECK( lexical_cast<T>("30000") == static_cast<T>(30000) );
}
test_conversion_from_integral_to_integral<T>();
test_conversion_from_integral_to_string<T>('0');
test_conversion_from_string_to_integral<T>('0');
#if !defined(BOOST_LCAST_NO_WCHAR_T)
test_conversion_from_integral_to_string<T>(L'0');
test_conversion_from_string_to_integral<T>(L'0');
#endif
}
struct restore_oldloc
{
std::locale oldloc;
~restore_oldloc() { std::locale::global(oldloc); }
};
template<class T>
void test_conversion_from_to_integral()
{
char const zero = '0';
signed char const szero = '0';
unsigned char const uzero = '0';
test_conversion_from_integral_to_char<T>(zero);
test_conversion_from_char_to_integral<T>(zero);
test_conversion_from_integral_to_char<T>(szero);
test_conversion_from_char_to_integral<T>(szero);
test_conversion_from_integral_to_char<T>(uzero);
test_conversion_from_char_to_integral<T>(uzero);
#if !defined(BOOST_LCAST_NO_WCHAR_T) && !defined(BOOST_NO_INTRINSIC_WCHAR_T)
wchar_t const wzero = L'0';
test_conversion_from_integral_to_char<T>(wzero);
test_conversion_from_char_to_integral<T>(wzero);
#endif
#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
#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);
#endif
BOOST_CHECK(lexical_cast<T>("-1") == static_cast<T>(-1));
BOOST_CHECK(lexical_cast<T>("-9") == static_cast<T>(-9));
BOOST_CHECK(lexical_cast<T>(-1) == static_cast<T>(-1));
BOOST_CHECK(lexical_cast<T>(-9) == static_cast<T>(-9));
BOOST_CHECK_THROW(lexical_cast<T>("-1.0"), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>("-9.0"), bad_lexical_cast);
BOOST_CHECK(lexical_cast<T>(-1.0) == static_cast<T>(-1));
BOOST_CHECK(lexical_cast<T>(-9.0) == static_cast<T>(-9));
BOOST_CHECK(lexical_cast<T>(static_cast<T>(1)) == static_cast<T>(1));
BOOST_CHECK(lexical_cast<T>(static_cast<T>(9)) == static_cast<T>(9));
BOOST_CHECK_THROW(lexical_cast<T>(1.1f), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>(1.1), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>(1.1L), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>(1.0001f), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>(1.0001), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>(1.0001L), bad_lexical_cast);
BOOST_CHECK(lexical_cast<T>("+1") == static_cast<T>(1) );
BOOST_CHECK(lexical_cast<T>("+9") == static_cast<T>(9) );
BOOST_CHECK(lexical_cast<T>("+10") == static_cast<T>(10) );
BOOST_CHECK(lexical_cast<T>("+90") == static_cast<T>(90) );
BOOST_CHECK_THROW(lexical_cast<T>("++1"), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>("-+9"), bad_lexical_cast);
BOOST_CHECK_THROW(lexical_cast<T>("--1"), bad_lexical_cast);
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;
std::locale const& oldloc = guard.oldloc;
std::string grouping1 = BOOST_USE_FACET(numpunct, oldloc).grouping();
std::string grouping2(grouping1);
test_conversion_from_to_integral_for_locale<T>();
try
{
std::locale newloc("");
std::locale::global(newloc);
grouping2 = BOOST_USE_FACET(numpunct, newloc).grouping();
}
catch(std::exception const& ex)
{
std::string msg("Failed to set system locale: ");
msg += ex.what();
BOOST_TEST_MESSAGE(msg);
}
if(grouping1 != grouping2)
test_conversion_from_to_integral_for_locale<T>();
if(grouping1.empty() && grouping2.empty())
BOOST_TEST_MESSAGE("Formatting with thousands_sep has not been tested");
}
void test_conversion_from_to_short()
{
test_conversion_from_to_integral<short>();
}
void test_conversion_from_to_ushort()
{
test_conversion_from_to_integral<unsigned short>();
}
void test_conversion_from_to_int()
{
test_conversion_from_to_integral<int>();
}
void test_conversion_from_to_uint()
{
test_conversion_from_to_integral<unsigned int>();
}
void test_conversion_from_to_long()
{
test_conversion_from_to_integral<long>();
}
void test_conversion_from_to_ulong()
{
test_conversion_from_to_integral<unsigned long>();
}
void test_conversion_from_to_intmax_t()
{
test_conversion_from_to_integral<boost::intmax_t>();
}
void test_conversion_from_to_uintmax_t()
{
test_conversion_from_to_integral<boost::uintmax_t>();
}
#if defined(BOOST_HAS_LONG_LONG)
void test_conversion_from_to_longlong()
{
test_conversion_from_to_integral<boost::long_long_type>();
}
void test_conversion_from_to_ulonglong()
{
test_conversion_from_to_integral<boost::ulong_long_type>();
}
#elif defined(BOOST_HAS_MS_INT64)
void test_conversion_from_to_longlong()
{
test_conversion_from_to_integral<__int64>();
}
void test_conversion_from_to_ulonglong()
{
test_conversion_from_to_integral<unsigned __int64>();
}
#endif
-13
View File
@@ -46,37 +46,24 @@ 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<int>(rng.begin(), rng.size()), 1);
BOOST_CHECK_EQUAL(lexical_cast<unsigned int>(rng), 1u);
BOOST_CHECK_EQUAL(lexical_cast<unsigned int>(rng.begin(), rng.size()), 1u);
BOOST_CHECK_EQUAL(lexical_cast<short>(rng), 1);
BOOST_CHECK_EQUAL(lexical_cast<short>(rng.begin(), rng.size()), 1);
BOOST_CHECK_EQUAL(lexical_cast<unsigned short>(rng), 1u);
BOOST_CHECK_EQUAL(lexical_cast<unsigned short>(rng.begin(), rng.size()), 1u);
BOOST_CHECK_EQUAL(lexical_cast<long int>(rng), 1);
BOOST_CHECK_EQUAL(lexical_cast<long int>(rng.begin(), rng.size()), 1);
BOOST_CHECK_EQUAL(lexical_cast<unsigned long int>(rng), 1u);
BOOST_CHECK_EQUAL(lexical_cast<unsigned long int>(rng.begin(), rng.size()), 1u);
#ifdef BOOST_STL_SUPPORTS_NEW_UNICODE_LOCALES
BOOST_CHECK_EQUAL(lexical_cast<float>(rng), 1.0f);
BOOST_CHECK_EQUAL(lexical_cast<float>(rng.begin(), rng.size()), 1.0f);
BOOST_CHECK_EQUAL(lexical_cast<double>(rng), 1.0);
BOOST_CHECK_EQUAL(lexical_cast<double>(rng.begin(), rng.size()), 1.0);
BOOST_CHECK_EQUAL(lexical_cast<long double>(rng), 1.0L);
BOOST_CHECK_EQUAL(lexical_cast<long double>(rng.begin(), rng.size()), 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::ulong_long_type>(rng.begin(), rng.size()), 1u);
BOOST_CHECK_EQUAL(lexical_cast<boost::long_long_type>(rng), 1);
BOOST_CHECK_EQUAL(lexical_cast<boost::long_long_type>(rng.begin(), rng.size()), 1);
#elif defined(BOOST_HAS_MS_INT64)
BOOST_CHECK_EQUAL(lexical_cast<unsigned __int64>(rng), 1u);
BOOST_CHECK_EQUAL(lexical_cast<unsigned __int64>(rng.begin(), rng.size()), 1u);
BOOST_CHECK_EQUAL(lexical_cast<__int64>(rng), 1);
BOOST_CHECK_EQUAL(lexical_cast<__int64>(rng.begin(), rng.size()), 1);
#endif
}