Lexical Cast
Lexical Cast
Lexical Cast
0
Copyright 2000-2005 Kevlin Henney Copyright 2006-2010 Alexander Nasonov Copyright 2011, 2012 Antony Polukhin Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Table of Contents
Motivation ............................................................................................................................................................ 2 Examples ............................................................................................................................................................. 3 Synopsis ............................................................................................................................................................... 4 lexical_cast ................................................................................................................................................... 4 bad_lexical_cast ............................................................................................................................................ 5 Frequently Asked Questions ..................................................................................................................................... 6 Changes ............................................................................................................................................................... 8 Performance ........................................................................................................................................................ 10 Tests description .......................................................................................................................................... 10 Clang version 3.0 (tags/RELEASE_30/nal) ..................................................................................................... 11 GNU C++ version 4.6.3 ................................................................................................................................. 18 GNU C++ version 4.5.3 ................................................................................................................................. 25 GNU C++ version 4.4.7 ................................................................................................................................. 32
Boost.Lexical_Cast 1.0
Motivation
Sometimes a value must be converted to a literal text form, such as an int represented as a std::string, or vice-versa, when a std::string is interpreted as an int. Such examples are common when converting between data types internal to a program and representation external to a program, such as windows and conguration les. The standard C and C++ libraries offer a number of facilities for performing such conversions. However, they vary with their ease of use, extensibility, and safety. For instance, there are a number of limitations with the family of standard C functions typied by atoi: Conversion is supported in one direction only: from text to internal data type. Converting the other way using the C library requires either the inconvenience and compromised safety of the sprintf function, or the loss of portability associated with non-standard functions such as itoa. The range of types supported is only a subset of the built-in numeric types, namely int, long, and double. The range of types cannot be extended in a uniform manner. For instance, conversion from string representation to complex or rational. The standard C functions typied by strtol have the same basic limitations, but offer ner control over the conversion process. However, for the common case such control is often either not required or not used. The scanf family of functions offer even greater control, but also lack safety and ease of use. The standard C++ library offers stringstream for the kind of in-core formatting being discussed. It offers a great deal of control over the formatting and conversion of I/O to and from arbitrary types through text. However, for simple conversions direct use of stringstream can be either clumsy (with the introduction of extra local variables and the loss of inx-expression convenience) or obscure (where stringstream objects are created as temporary objects in an expression). Facets provide a comprehensive concept and facility for controlling textual representation, but their perceived complexity and high entry level requires an extreme degree of involvement for simple conversions, and excludes all but a few programmers. The lexical_cast function template offers a convenient and consistent form for supporting common conversions to and from arbitrary types when they are represented as text. The simplication it offers is in expression-level convenience for such conversions. For more involved conversions, such as where precision or formatting need tighter control than is offered by the default behavior of lexical_cast, the conventional std::stringstream approach is recommended. Where the conversions are numeric to numeric, boost::numeric_cast may offer more reasonable behavior than lexical_cast. For a good discussion of the options and issues involved in string-based formatting, including comparison of stringstream, lexical_cast, and others, see Herb Sutter's article, The String Formatters of Manor Farm. Also, take a look at the Performance section.
Boost.Lexical_Cast 1.0
Examples
The following example treats command line arguments as a sequence of numeric data:
int main(int argc, char * argv[]) { using boost::lexical_cast; using boost::bad_lexical_cast; std::vector<short> args; while(*++argv) { try { args.push_back(lexical_cast<short>(*argv)); } catch(bad_lexical_cast &) { args.push_back(0); } } ... }
Boost.Lexical_Cast 1.0
Synopsis
Library features dened in boost/lexical_cast.hpp:
namespace boost { class bad_lexical_cast; template<typename Target, typename Source> Target lexical_cast(const Source& arg); }
lexical_cast
template<typename Target, typename Source> Target lexical_cast(const Source& arg);
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: Source is OutputStreamable, meaning that an operator<< is dened 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 dened that takes a std::istream or std::wistream object on the left hand side and an instance of the result type on the right. Target is CopyConstructible [20.1.3]. Target is DefaultConstructible, meaning that it is possible to default-initialize an object of that type [8.5, 20.1.4]. The character type of the underlying stream is assumed to be char unless either the Source or the Target requires wide-character streaming, in which case the underlying stream uses wchar_t, char16_t or char32_t. Wide-character streaming is currently detected for: Single character: wchar_t, char16_t, char32_t Arrays of characters: wchar_t *, char16_t *, char32_t *, const wchar_t *, const char16_t *, const char32_t
*
Strings: std::basic_string, boost::containers::basic_string boost::iterator_range<WideCharPtr>, where WideCharPtr is a pointer to wide-character or pointer to const wide-character boost::array<CharT, N> and std::array<CharT, N>, boost::array<const CharT, N> and std::array<const
CharT, N>
Boost.Lexical_Cast 1.0
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:
std::cout << boost::lexical_cast<std::u32string>(1.0).size() << " " << boost::lexical_cast<std::u16string>(1.0).size();
Where a higher degree of control is required over conversions, std::stringstream and std::wstringstream offer a more appropriate path. Where non-stream-based conversions are required, lexical_cast is the wrong tool for the job and is not specialcased for such scenarios.
bad_lexical_cast
class bad_lexical_cast : public std::bad_cast { public: ... // same member function interface as std::exception };
Boost.Lexical_Cast 1.0
Question: Why does lexical_cast<unsigned char>("127") throw bad_lexical_cast? Answer: Lexical conversion to any char type is simply reading a byte from source. But since the source has more than one byte, the exception is thrown. Please use other integer types such as int or short int. If bounds checking is important, you can also call boost::numeric_cast: numeric_cast<unsigned char>(lexical_cast<int>("127"));
Question: What does lexical_cast<std::string> of an int8_t or uint8_t not do what I expect? Answer: As above, note that int8_t and uint8_t are actually chars and are formatted as such. To avoid this, cast to an integer type rst: lexical_cast<std::string>(static_cast<int>(n));
Question: The implementation always resets the ios_base::skipws ag of an underlying stream object. It breaks my operator>> that works only in presence of this ag. Can you remove code that resets the ag? Answer: May be in a future version. There is no requirement in Lexical Conversion Library Proposal for TR2, N1973 by Kevlin Henney and Beman Dawes to reset the ag but remember that Lexical Conversion Library Proposal for TR2, N1973 is not yet accepted by the committee. By the way, it's a great opportunity to make your operator>> conform to the standard. Read a good C++ book, study std::sentry and ios_state_saver.
Question: Why std::cout << boost::lexical_cast<unsigned int>("-1"); does not throw, but outputs 4294967295? Answer: boost::lexical_cast has the behavior of std::stringstream, which uses num_get functions of std::locale to convert numbers. If we look at the Programming languages C++, we'll see, that num_get uses the rules of scanf for conversions. And in the C99 standard for unsigned input value minus sign is optional, so if a negative number is read, no errors will arise and the result will be the two's complement.
Question: Why boost::lexical_cast<int>(L'A'); outputs 65 and boost::lexical_cast<wchar_t>(L"65"); does not throw? Answer: If you are using an old version of Visual Studio or compile code with /Zc:wchar_t- ag, boost::lexical_cast sees single wchar_t character as unsigned short. It is not a boost::lexical_cast mistake, but a limitation of compiler options that you use.
Question: Why boost::lexical_cast<double>("-1.#IND"); throws boost::bad_lexical_cast? Answer: "-1.#IND" is a compiler extension, that violates standard. You shall input "-nan", "nan", "inf" , "-inf" (case insensitive) strings to get NaN and Inf values. boost::lexical_cast<string> outputs "-nan", "nan", "inf", "-inf" strings, when has NaN or Inf input values.
Boost.Lexical_Cast 1.0
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);.
Boost.Lexical_Cast 1.0
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. Now it is possible to compile library with disabled exceptions. Better performance, less memory usage and bugxes for boost::iterator_range<character_type*> conversions. boost 1.49.0 : Restored work with typedefed wchar_t (compilation ag /Zc:wchar_t- for Visual Studio). Better performance and less memory usage for boost::container::basic_string conversions. boost 1.48.0 : Added code to work with Inf and NaN on any platform. Better performance and less memory usage for conversions to oat type (and to double type, if sizeof(double) < sizeof(long double)). boost 1.47.0 : Optimizations for "C" and other locales without number grouping. Better performance and less memory usage for unsigned char and signed char conversions. Better performance and less memory usage for conversions to arithmetic types. Better performance and less memory usage for conversions from arithmetic type to arithmetic type. Directly construct Target from Source on some conversions (like conversions from string to string, from char array to string, from char to char and others). boost 1.34.0 : Better performance for many combinations of Source and Target types. For more details refer to Alexander Nasonovs article Fine Tuning for lexical_cast, Overload #74, August 2006 (PDF). boost 1.33.0 : Call-by-const reference for the parameters. This requires partial specialization of class templates, so it doesn't work for MSVC 6, and it uses the original pass by value there. The MSVC 6 support is deprecated, and will be removed in a future Boost version. Earlier :
Boost.Lexical_Cast 1.0
The previous version of lexical_cast used the default stream precision for reading and writing oating-point numbers. For numerics that have a corresponding specialization of std::numeric_limits, the current version now chooses a precision to match. The previous version of lexical_cast did not support conversion to or from any wide-character-based types. For compilers with full language and library support for wide characters, lexical_cast now supports conversions from wchar_t, wchar_t *, and std::wstring and to wchar_t and std::wstring. The previous version of lexical_cast assumed that the conventional stream extractor operators were sufcient for reading values. However, string I/O is asymmetric, with the result that spaces play the role of I/O separators rather than string content. The current version xes this error for std::string and, where supported, std::wstring: lexical_cast<std::string>("Hello, World") succeeds instead of failing with a bad_lexical_cast exception. The previous version of lexical_cast allowed unsafe and meaningless conversions to pointers. The current version now throws a bad_lexical_cast for conversions to pointers: lexical_cast<char *>("Goodbye, World") now throws an exception instead of causing undened behavior.
Boost.Lexical_Cast 1.0
Performance
In most cases boost::lexical_cast is faster than scanf, printf, std::stringstream. For more detailed info you can look at the tables below.
Tests description
All the tests measure execution speed in milliseconds for 10000 iterations of the following code blocks:
std::stringstream ss; ss << _in; if (ss.fail()) throw std::logic_error(descr); ss >> _out; if (ss.fail()) throw std::logic_error(descr);
ss << _in; // ss is an instance of std::string stream if (ss.fail()) throw std::logic_error(descr); ss >> _out; if (ss.fail()) throw std::logic_error(descr); /* reseting std::stringstream to use it again */ ss.str(std::string()); ss.clear();
scanf/printf
Fastest results are highlitened with "!!! x !!!". Do not use this results to compare compilers, because tests were taken on different hardware.
10
Boost.Lexical_Cast 1.0
11
Boost.Lexical_Cast 1.0
string->char string->signed char string->unsigned char string->int string->short string->long int string->long long string->unsigned int string->unsigned short string->unsigned long int string->unsigned long long string->oat string->double string->long double string->array<char, 50> string->string string->container::string string->char string->signed char string->unsigned char int->string short->string long int->string long long->string unsigned int->string unsigned short->string
!!! <1 !!! !!! <1 !!! !!! <1 !!! !!! 6 !!! !!! 7 !!! !!! 7 !!! !!! 8 !!! !!! 6 !!! !!! 6 !!! !!! 7 !!!
10 10 10 24 24 22 23 23 22 21
!!! 8 !!!
118
19
34
!!! 13 !!! !!! 14 !!! 195 !!! <1 !!! !!! 1 !!! !!! 3 !!! 7 !!! 6 !!! !!! 6 !!! !!! 12 !!! !!! 11 !!! !!! 11 !!! !!! 12 !!! !!! 11 !!! !!! 11 !!!
201 151 231 121 124 114 111 112 113 126 135 128 126 131 130
55 54 67 18 27 25 25 30 25 36 30 28 32 36 28
12
Boost.Lexical_Cast 1.0
From->To
lexical_cast
scanf/printf
unsigned >string
long
int-
!!! 11 !!!
22
unsigned long long>string oat->string double->string long double->string char*->char char*->signed char char*->unsigned char char*->int char*->short char*->long int char*->long long char*->unsigned int char*->unsigned short char*->unsigned long int char*->unsigned long long char*->oat char*->double char*->long double char*->array<char, 50> char*->string char*->container::string unsigned char*->char unsigned char*->signed char unsigned char*->unsigned char
!!! 11 !!!
127
43
25
53 59 118 !!! 1 !!! !!! 1 !!! !!! 1 !!! !!! 7 !!! !!! 7 !!! !!! 9 !!! !!! 9 !!! !!! 7 !!! !!! 7 !!! !!! 8 !!!
190 197 229 105 107 106 149 118 117 128 120 125 125
83 82 101 9 10 9 25 20 20 23 19 20 21
!!! 8 !!!
130
19
22
!!! 14 !!! !!! 16 !!! 111 !!! 1 !!! !!! 8 !!! !!! 2 !!! !!! 1 !!! !!! 1 !!!
56 54 58 20 27 26 9 9
!!! 1 !!!
103
13
13
Boost.Lexical_Cast 1.0
From->To
lexical_cast
scanf/printf
unsigned char*->int unsigned char*->short unsigned char*->long int unsigned char*->long long unsigned char*->unsigned int unsigned char*->unsigned short unsigned char*->unsigned long int unsigned char*->unsigned long long unsigned char*->oat unsigned char*->double unsigned char*->long double unsigned char*->array<char, 50> unsigned char*->string unsigned char*->container::string signed char*->char signed char*->signed char signed char*->unsigned char signed char*->int signed char*->short signed char*->long int signed long char*->long
24 26 22
!!! 8 !!!
122
20
23
!!! 6 !!!
119
22
23
!!! 7 !!!
122
20
22
!!! 8 !!!
125
21
22
!!! 8 !!!
122
19
25
62 58 58
37 39 !!! 42 !!!
!!! 1 !!!
122
19
15
124 119
27 25
-----
107 108
9 10
9 11
!!! 1 !!!
106
11
21 20 20 21
22 22 23 26
14
Boost.Lexical_Cast 1.0
From->To
lexical_cast
scanf/printf
signed char*->unsigned int signed char*->unsigned short signed char*->unsigned long int signed char*->unsigned long long signed char*->oat signed char*->double signed double char*->long
!!! 6 !!!
22
!!! 7 !!!
124
21
23
!!! 8 !!!
121
24
23
!!! 8 !!!
122
20
22
56 53 56
37 40 !!! 42 !!!
signed char*->array<char, 50> signed char*->string signed char*->container::string iterator_range<char*>>char iterator_range<char*>>signed char iterator_range<char*>>unsigned char iterator_range<char*>>int iterator_range<char*>>short iterator_range<char*>>long int iterator_range<char*>>long long iterator_range<char*>>unsigned int iterator_range<char*>>unsigned short
!!! 1 !!!
117
19
12
132 116
27 26
-----
112
14
107
13
10
145
15
10
!!! 6 !!!
119
22
23
!!! 6 !!!
115
22
23
!!! 7 !!!
115
25
22
!!! 7 !!!
117
21
23
!!! 6 !!!
118
22
22
!!! 6 !!!
117
24
22
15
Boost.Lexical_Cast 1.0
From->To
lexical_cast
scanf/printf
iterator_range<char*>>unsigned long int iterator_range<char*>>unsigned long long iterator_range<char*>>oat iterator_range<char*>>double iterator_range<char*>>long double iterator_range<char*>>array<char, 50> iterator_range<char*>>string iterator_range<char*>>container::string array<char, 50>->char array<char, >signed char 50>-
!!! 7 !!!
22
!!! 7 !!!
119
22
22
!!! 13 !!!
159
42
41
!!! 14 !!!
152
40
40
113
155
58
!!! 54 !!!
127
23
13
!!! 7 !!!
132
30
---
!!! 3 !!!
122
24
---
110 119
9 9
10 13
array<char, 50>->unsigned char array<char, 50>->int array<char, 50>->short array<char, 50>->long int array<char, 50>->long long array<char, 50>->unsigned int array<char, 50>->unsigned short array<char, 50>->unsigned long int array<char, 50>->unsigned long long
106
13
11
21 22 21
22 28 26
!!! 8 !!!
115
22
23
!!! 6 !!!
118
18
22
!!! 7 !!!
119
19
22
!!! 7 !!!
118
23
21
!!! 7 !!!
117
20
22
16
Boost.Lexical_Cast 1.0
From->To
lexical_cast
scanf/printf
36 39
array<char, 50>->long double array<char, 50>->array<char, 50> array<char, 50>->string array<char, 50>->container::string int->int oat->double char->signed char
110
150
56
!!! 41 !!!
117
19
12
124 115
26 26
-----
24 125 9
-------
17
Boost.Lexical_Cast 1.0
18
Boost.Lexical_Cast 1.0
string->char string->signed char string->unsigned char string->int string->short string->long int string->long long string->unsigned int string->unsigned short string->unsigned long int string->unsigned long long string->oat string->double string->long double string->array<char, 50> string->string string->container::string string->char string->signed char string->unsigned char int->string short->string long int->string long long->string unsigned int->string unsigned short->string
!!! <1 !!! !!! <1 !!! !!! <1 !!! !!! 7 !!! !!! 6 !!! !!! 7 !!! !!! 7 !!! !!! 6 !!! !!! 5 !!! !!! 7 !!!
18 10 10 24 25 24 23 23 23 23
!!! 7 !!!
108
20
22
!!! 11 !!! !!! 11 !!! 113 !!! <1 !!! !!! 2 !!! !!! 3 !!! !!! 7 !!! !!! 7 !!! !!! 7 !!! !!! 12 !!! !!! 13 !!! !!! 12 !!! !!! 13 !!! !!! 13 !!! !!! 12 !!!
161 146 151 107 127 142 110 114 110 127 129 125 127 127 127
54 56 59 18 24 26 23 23 25 31 31 30 34 27 28
19
Boost.Lexical_Cast 1.0
From->To
lexical_cast
scanf/printf
unsigned >string
long
int-
!!! 12 !!!
22
unsigned long long>string oat->string double->string long double->string char*->char char*->signed char char*->unsigned char char*->int char*->short char*->long int char*->long long char*->unsigned int char*->unsigned short char*->unsigned long int char*->unsigned long long char*->oat char*->double char*->long double char*->array<char, 50> char*->string char*->container::string unsigned char*->char unsigned char*->signed char unsigned char*->unsigned char
!!! 12 !!!
125
28
24
51 56 65 !!! <1 !!! !!! <1 !!! !!! <1 !!! !!! 6 !!! !!! 6 !!! !!! 8 !!! !!! 9 !!! !!! 7 !!! !!! 6 !!! !!! 7 !!!
200 194 220 104 101 99 112 115 111 112 112 119 115
81 82 82 10 10 10 23 21 21 21 22 19 22
!!! 7 !!!
115
20
23
!!! 12 !!! !!! 12 !!! 108 !!! <1 !!! !!! 7 !!! !!! 2 !!! !!! <1 !!! !!! <1 !!!
54 61 61 20 26 24 10 10
99
11
12
20
Boost.Lexical_Cast 1.0
From->To
lexical_cast
scanf/printf
unsigned char*->int unsigned char*->short unsigned char*->long int unsigned char*->long long unsigned char*->unsigned int unsigned char*->unsigned short unsigned char*->unsigned long int unsigned char*->unsigned long long unsigned char*->oat unsigned char*->double unsigned char*->long double unsigned char*->array<char, 50> unsigned char*->string unsigned char*->container::string signed char*->char signed char*->signed char signed char*->unsigned char signed char*->int signed char*->short signed char*->long int signed long char*->long
24 24 24
!!! 9 !!!
115
21
25
!!! 6 !!!
111
24
23
!!! 6 !!!
118
19
23
!!! 8 !!!
112
21
23
!!! 13 !!!
109
20
23
56 58 68
39 41 !!! 43 !!!
!!! 1 !!!
107
19
15
124 121
26 24
-----
99 99
10 10
9 10
99
10
12
28 21 21 21
24 25 24 24
21
Boost.Lexical_Cast 1.0
From->To
lexical_cast
scanf/printf
signed char*->unsigned int signed char*->unsigned short signed char*->unsigned long int signed char*->unsigned long long signed char*->oat signed char*->double signed double char*->long
!!! 7 !!!
23
!!! 6 !!!
116
20
23
!!! 8 !!!
113
27
23
!!! 8 !!!
110
20
23
53 60 62
44 42 !!! 44 !!!
signed char*->array<char, 50> signed char*->string signed char*->container::string iterator_range<char*>>char iterator_range<char*>>signed char iterator_range<char*>>unsigned char iterator_range<char*>>int iterator_range<char*>>short iterator_range<char*>>long int iterator_range<char*>>long long iterator_range<char*>>unsigned int iterator_range<char*>>unsigned short
!!! 1 !!!
107
19
15
124 121
26 24
-----
103
14
10
102
15
12
102
14
12
!!! 6 !!!
115
23
24
!!! 5 !!!
110
22
24
!!! 7 !!!
109
22
29
!!! 7 !!!
111
24
28
!!! 6 !!!
114
22
23
!!! 5 !!!
115
20
22
22
Boost.Lexical_Cast 1.0
From->To
lexical_cast
scanf/printf
iterator_range<char*>>unsigned long int iterator_range<char*>>unsigned long long iterator_range<char*>>oat iterator_range<char*>>double iterator_range<char*>>long double iterator_range<char*>>array<char, 50> iterator_range<char*>>string iterator_range<char*>>container::string array<char, 50>->char array<char, >signed char 50>-
!!! 7 !!!
23
!!! 7 !!!
110
23
24
!!! 11 !!!
153
38
38
!!! 11 !!!
140
43
40
108
147
!!! 41 !!!
46
109
22
15
!!! 8 !!!
122
29
---
!!! 3 !!!
117
23
---
98 99
10 9
9 12
array<char, 50>->unsigned char array<char, 50>->int array<char, 50>->short array<char, 50>->long int array<char, 50>->long long array<char, 50>->unsigned int array<char, 50>->unsigned short array<char, 50>->unsigned long int array<char, 50>->unsigned long long
102
12
23 21 20
23 26 28
!!! 9 !!!
110
21
26
!!! 6 !!!
115
22
23
!!! 6 !!!
115
19
23
!!! 7 !!!
118
23
23
!!! 7 !!!
109
20
24
23
Boost.Lexical_Cast 1.0
From->To
lexical_cast
scanf/printf
38 41
array<char, 50>->long double array<char, 50>->array<char, 50> array<char, 50>->string array<char, 50>->container::string int->int oat->double char->signed char
109
154
59
!!! 42 !!!
!!! 1 !!!
105
19
14
129 116
26 25
-----
118 242 94
24 132 8
-------
24
Boost.Lexical_Cast 1.0
25
Boost.Lexical_Cast 1.0
string->char string->signed char string->unsigned char string->int string->short string->long int string->long long string->unsigned int string->unsigned short string->unsigned long int string->unsigned long long string->oat string->double string->long double string->array<char, 50> string->string string->container::string string->char string->signed char string->unsigned char int->string short->string long int->string long long->string unsigned int->string unsigned short->string
!!! <1 !!! !!! <1 !!! !!! <1 !!! !!! 7 !!! !!! 5 !!! !!! 7 !!! !!! 7 !!! !!! 6 !!! !!! 5 !!! !!! 7 !!!
9 10 14 22 21 24 23 23 23 23
!!! 7 !!!
115
18
23
!!! 14 !!! !!! 11 !!! 107 !!! <1 !!! !!! 2 !!! !!! 9 !!! !!! 7 !!! !!! 7 !!! !!! 7 !!! !!! 11 !!! !!! 11 !!! !!! 11 !!! !!! 11 !!! !!! 11 !!! !!! 12 !!!
153 151 151 107 129 199 114 116 114 125 126 126 118 125 128
55 60 59 18 49 22 27 32 27 31 33 32 30 31 30
26
Boost.Lexical_Cast 1.0
From->To
lexical_cast
scanf/printf
unsigned >string
long
int-
!!! 11 !!!
21
unsigned long long>string oat->string double->string long double->string char*->char char*->signed char char*->unsigned char char*->int char*->short char*->long int char*->long long char*->unsigned int char*->unsigned short char*->unsigned long int char*->unsigned long long char*->oat char*->double char*->long double char*->array<char, 50> char*->string char*->container::string unsigned char*->char unsigned char*->signed char unsigned char*->unsigned char
!!! 11 !!!
127
32
23
49 56 60 !!! <1 !!! !!! <1 !!! !!! <1 !!! !!! 7 !!! !!! 6 !!! !!! 8 !!! !!! 8 !!! !!! 6 !!! !!! 6 !!! !!! 8 !!!
197 195 222 100 99 106 113 113 116 115 114 119 114
92 80 88 10 10 10 23 21 21 21 25 20 23
!!! 7 !!!
111
20
24
!!! 16 !!! !!! 12 !!! 107 !!! 1 !!! !!! 8 !!! !!! 2 !!! !!! <1 !!! !!! <1 !!!
54 59 62 20 28 24 11 10
101
10
10
27
Boost.Lexical_Cast 1.0
From->To
lexical_cast
scanf/printf
unsigned char*->int unsigned char*->short unsigned char*->long int unsigned char*->long long unsigned char*->unsigned int unsigned char*->unsigned short unsigned char*->unsigned long int unsigned char*->unsigned long long unsigned char*->oat unsigned char*->double unsigned char*->long double unsigned char*->array<char, 50> unsigned char*->string unsigned char*->container::string signed char*->char signed char*->signed char signed char*->unsigned char signed char*->int signed char*->short signed char*->long int signed long char*->long
24 22 23
!!! 8 !!!
114
21
23
!!! 7 !!!
115
20
25
!!! 6 !!!
113
20
22
!!! 8 !!!
115
25
24
!!! 7 !!!
113
25
25
55 62 60
38 40 !!! 41 !!!
!!! 1 !!!
111
19
12
125 121
30 23
-----
98 98
14 11
9 10
99
10
10
22 22 21 24
24 23 23 24
28
Boost.Lexical_Cast 1.0
From->To
lexical_cast
scanf/printf
signed char*->unsigned int signed char*->unsigned short signed char*->unsigned long int signed char*->unsigned long long signed char*->oat signed char*->double signed double char*->long
!!! 6 !!!
22
!!! 6 !!!
112
21
24
!!! 8 !!!
114
23
22
!!! 8 !!!
116
22
24
55 59 60
38 39 !!! 44 !!!
signed char*->array<char, 50> signed char*->string signed char*->container::string iterator_range<char*>>char iterator_range<char*>>signed char iterator_range<char*>>unsigned char iterator_range<char*>>int iterator_range<char*>>short iterator_range<char*>>long int iterator_range<char*>>long long iterator_range<char*>>unsigned int iterator_range<char*>>unsigned short
!!! 1 !!!
107
24
12
122 122
28 23
-----
103
13
10
103
13
10
104
14
10
!!! 6 !!!
115
23
24
!!! 7 !!!
111
21
24
!!! 7 !!!
108
21
23
!!! 7 !!!
114
24
23
!!! 6 !!!
111
22
23
!!! 5 !!!
114
20
23
29
Boost.Lexical_Cast 1.0
From->To
lexical_cast
scanf/printf
iterator_range<char*>>unsigned long int iterator_range<char*>>unsigned long long iterator_range<char*>>oat iterator_range<char*>>double iterator_range<char*>>long double iterator_range<char*>>array<char, 50> iterator_range<char*>>string iterator_range<char*>>container::string array<char, 50>->char array<char, >signed char 50>-
!!! 7 !!!
24
!!! 7 !!!
110
20
24
!!! 15 !!!
148
38
40
!!! 10 !!!
146
41
40
103
138
!!! 39 !!!
42
109
22
13
!!! 7 !!!
121
32
---
!!! 3 !!!
120
24
---
102 97
9 9
9 10
array<char, 50>->unsigned char array<char, 50>->int array<char, 50>->short array<char, 50>->long int array<char, 50>->long long array<char, 50>->unsigned int array<char, 50>->unsigned short array<char, 50>->unsigned long int array<char, 50>->unsigned long long
99
10
22 21 20
23 23 23
!!! 7 !!!
114
21
23
!!! 7 !!!
119
20
25
!!! 6 !!!
120
20
23
!!! 7 !!!
113
20
21
!!! 7 !!!
112
20
24
30
Boost.Lexical_Cast 1.0
From->To
lexical_cast
scanf/printf
38 42
array<char, 50>->long double array<char, 50>->array<char, 50> array<char, 50>->string array<char, 50>->container::string int->int oat->double char->signed char
107
152
60
!!! 41 !!!
!!! 1 !!!
111
20
12
123 128
36 23
-----
118 233 97
26 120 8
-------
31
Boost.Lexical_Cast 1.0
32
Boost.Lexical_Cast 1.0
string->char string->signed char string->unsigned char string->int string->short string->long int string->long long string->unsigned int string->unsigned short string->unsigned long int string->unsigned long long string->oat string->double string->long double string->array<char, 50> string->string string->container::string string->char string->signed char string->unsigned char int->string short->string long int->string long long->string unsigned int->string unsigned short->string
!!! <1 !!! !!! <1 !!! !!! <1 !!! !!! 6 !!! !!! 5 !!! !!! 7 !!! !!! 7 !!! !!! 7 !!! !!! 5 !!! !!! 7 !!!
9 10 11 23 29 26 23 23 22 23
!!! 9 !!!
116
26
24
!!! 12 !!! !!! 12 !!! 112 !!! <1 !!! !!! 2 !!! !!! 2 !!! !!! 7 !!! !!! 6 !!! !!! 6 !!! !!! 11 !!! !!! 12 !!! !!! 15 !!! !!! 11 !!! !!! 13 !!! !!! 11 !!!
165 154 148 120 141 164 161 109 109 128 136 187 128 124 128
53 54 61 19 55 36 24 25 25 32 54 41 30 29 30
33
Boost.Lexical_Cast 1.0
From->To
lexical_cast
scanf/printf
unsigned >string
long
int-
!!! 11 !!!
22
unsigned long long>string oat->string double->string long double->string char*->char char*->signed char char*->unsigned char char*->int char*->short char*->long int char*->long long char*->unsigned int char*->unsigned short char*->unsigned long int char*->unsigned long long char*->oat char*->double char*->long double char*->array<char, 50> char*->string char*->container::string unsigned char*->char unsigned char*->signed char unsigned char*->unsigned char
!!! 11 !!!
133
33
29
52 58 70 !!! <1 !!! !!! <1 !!! !!! <1 !!! !!! 6 !!! !!! 6 !!! !!! 7 !!! !!! 7 !!! !!! 6 !!! !!! 6 !!! !!! 7 !!!
187 190 218 99 99 100 117 115 119 114 113 120 117
90 86 88 11 11 12 23 28 22 23 21 21 25
!!! 7 !!!
119
23
21
!!! 13 !!! !!! 13 !!! 116 !!! 1 !!! !!! 7 !!! !!! 2 !!! !!! <1 !!! !!! <1 !!!
61 54 58 20 29 27 12 11
95
12
12
34
Boost.Lexical_Cast 1.0
From->To
lexical_cast
scanf/printf
unsigned char*->int unsigned char*->short unsigned char*->long int unsigned char*->long long unsigned char*->unsigned int unsigned char*->unsigned short unsigned char*->unsigned long int unsigned char*->unsigned long long unsigned char*->oat unsigned char*->double unsigned char*->long double unsigned char*->array<char, 50> unsigned char*->string unsigned char*->container::string signed char*->char signed char*->signed char signed char*->unsigned char signed char*->int signed char*->short signed char*->long int signed long char*->long
24 21 23
!!! 7 !!!
114
23
23
!!! 6 !!!
115
23
23
!!! 6 !!!
120
21
23
!!! 7 !!!
117
23
21
!!! 7 !!!
121
23
21
58 54 62
39 38 !!! 43 !!!
!!! 1 !!!
113
20
12
124 118
30 27
-----
99 102
11 12
9 10
99
12
10
30 23 22 23
23 23 21 26
35
Boost.Lexical_Cast 1.0
From->To
lexical_cast
scanf/printf
signed char*->unsigned int signed char*->unsigned short signed char*->unsigned long int signed char*->unsigned long long signed char*->oat signed char*->double signed double char*->long
!!! 6 !!!
23
!!! 6 !!!
121
22
23
!!! 7 !!!
126
23
21
!!! 7 !!!
114
22
21
57 53 56
39 40 !!! 42 !!!
signed char*->array<char, 50> signed char*->string signed char*->container::string iterator_range<char*>>char iterator_range<char*>>signed char iterator_range<char*>>unsigned char iterator_range<char*>>int iterator_range<char*>>short iterator_range<char*>>long int iterator_range<char*>>long long iterator_range<char*>>unsigned int iterator_range<char*>>unsigned short
!!! 1 !!!
117
20
12
127 112
28 27
-----
103
14
104
16
10
103
16
10
!!! 6 !!!
121
22
21
!!! 7 !!!
112
23
23
!!! 7 !!!
115
24
23
!!! 7 !!!
113
24
23
!!! 6 !!!
117
26
23
!!! 5 !!!
120
20
23
36
Boost.Lexical_Cast 1.0
From->To
lexical_cast
scanf/printf
iterator_range<char*>>unsigned long int iterator_range<char*>>unsigned long long iterator_range<char*>>oat iterator_range<char*>>double iterator_range<char*>>long double iterator_range<char*>>array<char, 50> iterator_range<char*>>string iterator_range<char*>>container::string array<char, 50>->char array<char, >signed char 50>-
!!! 7 !!!
21
!!! 7 !!!
113
22
21
!!! 11 !!!
190
58
63
!!! 20 !!!
194
44
39
116
145
46
!!! 44 !!!
116
23
15
!!! 7 !!!
127
33
---
!!! 3 !!!
112
24
---
98 99
11 12
10 15
array<char, 50>->unsigned char array<char, 50>->int array<char, 50>->short array<char, 50>->long int array<char, 50>->long long array<char, 50>->unsigned int array<char, 50>->unsigned short array<char, 50>->unsigned long int array<char, 50>->unsigned long long
100
11
10
27 23 22
22 23 23
!!! 7 !!!
114
26
23
!!! 6 !!!
113
27
23
!!! 5 !!!
124
21
23
!!! 7 !!!
116
23
21
!!! 7 !!!
115
22
21
37
Boost.Lexical_Cast 1.0
From->To
lexical_cast
scanf/printf
36 44
array<char, 50>->long double array<char, 50>->array<char, 50> array<char, 50>->string array<char, 50>->container::string int->int oat->double char->signed char
111
149
55
!!! 42 !!!
!!! 1 !!!
114
18
14
129 113
29 26
-----
114 236 97
25 121 8
-------
38