From 675d0bb4516025323a5ff5dd67aa12368abf22e5 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Sun, 8 Jul 2012 18:06:32 +0000 Subject: [PATCH] Merge from trunk (now lexical_cast has optimized conversions to and from array<>, fixes #7065) [SVN r79364] --- doc/lexical_cast.qbk | 920 ++++++++++++---------- include/boost/lexical_cast.hpp | 231 +++++- lexical_cast_test.cpp | 477 +---------- perf/performance_test.cpp | 47 +- test/Jamfile.v2 | 2 + test/implicit_cast.cpp | 2 +- test/implicit_cast_fail.cpp | 2 + test/lexical_cast_arrays_test.cpp | 367 +++++++++ test/lexical_cast_integral_types_test.cpp | 539 +++++++++++++ 9 files changed, 1670 insertions(+), 917 deletions(-) create mode 100644 test/lexical_cast_arrays_test.cpp create mode 100644 test/lexical_cast_integral_types_test.cpp diff --git a/doc/lexical_cast.qbk b/doc/lexical_cast.qbk index b856594..59309d2 100644 --- a/doc/lexical_cast.qbk +++ b/doc/lexical_cast.qbk @@ -70,6 +70,15 @@ The following example uses numeric data in a string expression: log_message("Error " + boost::lexical_cast(yoko) + ": " + strerror(yoko)); } `` +Following example converts some number and puts it to file: +`` + int i; + FILE* file; + ... + typedef boost::array buf_t; // You can use std::array if your compiler supports it + buf_t buffer = boost::lexical_cast(i); // No dynamic memory allocation + puts(buffer.begin(), file); +`` [endsect] [section Synopsis] @@ -103,6 +112,7 @@ 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`, where `WideCharPtr` is a pointer to wide-character or pointer to const wide-character +* `boost::array` and `std::array`, `boost::array` and `std::array` [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: `` @@ -239,12 +249,20 @@ limitation of compiler options that you use. , `"-inf"` (case insensitive) strings to get NaN and Inf values. `boost::lexical_cast` 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. For example, if you whant to convert to `int` two characters from a string `str`, you shall write `lexacal_cast(make_iterator_range(str.c_str(), str.c_str() + 2));`. [endsect] [section Changes] + +* [*boost 1.51.0 :] + + * Better performance, less memory usage for `boost::array` and `std::array` 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. @@ -335,417 +353,507 @@ 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 2.9 (tags/RELEASE_29/final)] -[table:id Performance Table ( Clang version 2.9 (tags/RELEASE_29/final)) + +[section Clang version 3.0 (tags/RELEASE_30/final)] +[table:id Performance Table ( Clang version 3.0 (tags/RELEASE_30/final)) [[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] - [[ 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* !!! ]] + [[ 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 ][ !!! *<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 ][ !!! *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 ][ !!! *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 ][ !!! *1* !!! ][ 117 ][ 19 ][ 12 ]] + [[ signed char*->string ][ !!! *8* !!! ][ 132 ][ 27 ][ --- ]] + [[ signed char*->container::string ][ !!! *4* !!! ][ 116 ][ 26 ][ --- ]] + [[ iterator_range->char ][ !!! *<1* !!! ][ 112 ][ 14 ][ 9 ]] + [[ iterator_range->signed char ][ !!! *<1* !!! ][ 107 ][ 13 ][ 10 ]] + [[ iterator_range->unsigned char ][ !!! *<1* !!! ][ 145 ][ 15 ][ 10 ]] + [[ iterator_range->int ][ !!! *6* !!! ][ 119 ][ 22 ][ 23 ]] + [[ iterator_range->short ][ !!! *6* !!! ][ 115 ][ 22 ][ 23 ]] + [[ iterator_range->long int ][ !!! *7* !!! ][ 115 ][ 25 ][ 22 ]] + [[ iterator_range->long long ][ !!! *7* !!! ][ 117 ][ 21 ][ 23 ]] + [[ iterator_range->unsigned int ][ !!! *6* !!! ][ 118 ][ 22 ][ 22 ]] + [[ iterator_range->unsigned short ][ !!! *6* !!! ][ 117 ][ 24 ][ 22 ]] + [[ iterator_range->unsigned long int ][ !!! *7* !!! ][ 124 ][ 25 ][ 22 ]] + [[ iterator_range->unsigned long long ][ !!! *7* !!! ][ 119 ][ 22 ][ 22 ]] + [[ iterator_range->float ][ !!! *13* !!! ][ 159 ][ 42 ][ 41 ]] + [[ iterator_range->double ][ !!! *14* !!! ][ 152 ][ 40 ][ 40 ]] + [[ iterator_range->long double ][ 113 ][ 155 ][ 58 ][ !!! *54* !!! ]] + [[ iterator_range->array ][ !!! *<1* !!! ][ 127 ][ 23 ][ 13 ]] + [[ iterator_range->string ][ !!! *7* !!! ][ 132 ][ 30 ][ --- ]] + [[ iterator_range->container::string ][ !!! *3* !!! ][ 122 ][ 24 ][ --- ]] + [[ array->char ][ !!! *<1* !!! ][ 110 ][ 9 ][ 10 ]] + [[ array->signed char ][ !!! *<1* !!! ][ 119 ][ 9 ][ 13 ]] + [[ array->unsigned char ][ !!! *<1* !!! ][ 106 ][ 13 ][ 11 ]] + [[ array->int ][ !!! *6* !!! ][ 131 ][ 21 ][ 22 ]] + [[ array->short ][ !!! *7* !!! ][ 119 ][ 22 ][ 28 ]] + [[ array->long int ][ !!! *8* !!! ][ 133 ][ 21 ][ 26 ]] + [[ array->long long ][ !!! *8* !!! ][ 115 ][ 22 ][ 23 ]] + [[ array->unsigned int ][ !!! *6* !!! ][ 118 ][ 18 ][ 22 ]] + [[ array->unsigned short ][ !!! *7* !!! ][ 119 ][ 19 ][ 22 ]] + [[ array->unsigned long int ][ !!! *7* !!! ][ 118 ][ 23 ][ 21 ]] + [[ array->unsigned long long ][ !!! *7* !!! ][ 117 ][ 20 ][ 22 ]] + [[ array->float ][ !!! *15* !!! ][ 156 ][ 53 ][ 36 ]] + [[ array->double ][ !!! *15* !!! ][ 148 ][ 55 ][ 39 ]] + [[ array->long double ][ 110 ][ 150 ][ 56 ][ !!! *41* !!! ]] + [[ array->array ][ !!! *<1* !!! ][ 117 ][ 19 ][ 12 ]] + [[ array->string ][ !!! *7* !!! ][ 124 ][ 26 ][ --- ]] + [[ array->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 ][ !!! *<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 ][ !!! *<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 ][ !!! *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 ][ !!! *1* !!! ][ 107 ][ 19 ][ 15 ]] + [[ signed char*->string ][ !!! *8* !!! ][ 124 ][ 26 ][ --- ]] + [[ signed char*->container::string ][ !!! *4* !!! ][ 121 ][ 24 ][ --- ]] + [[ iterator_range->char ][ !!! *<1* !!! ][ 103 ][ 14 ][ 10 ]] + [[ iterator_range->signed char ][ !!! *<1* !!! ][ 102 ][ 15 ][ 12 ]] + [[ iterator_range->unsigned char ][ !!! *<1* !!! ][ 102 ][ 14 ][ 12 ]] + [[ iterator_range->int ][ !!! *6* !!! ][ 115 ][ 23 ][ 24 ]] + [[ iterator_range->short ][ !!! *5* !!! ][ 110 ][ 22 ][ 24 ]] + [[ iterator_range->long int ][ !!! *7* !!! ][ 109 ][ 22 ][ 29 ]] + [[ iterator_range->long long ][ !!! *7* !!! ][ 111 ][ 24 ][ 28 ]] + [[ iterator_range->unsigned int ][ !!! *6* !!! ][ 114 ][ 22 ][ 23 ]] + [[ iterator_range->unsigned short ][ !!! *5* !!! ][ 115 ][ 20 ][ 22 ]] + [[ iterator_range->unsigned long int ][ !!! *7* !!! ][ 123 ][ 26 ][ 23 ]] + [[ iterator_range->unsigned long long ][ !!! *7* !!! ][ 110 ][ 23 ][ 24 ]] + [[ iterator_range->float ][ !!! *11* !!! ][ 153 ][ 38 ][ 38 ]] + [[ iterator_range->double ][ !!! *11* !!! ][ 140 ][ 43 ][ 40 ]] + [[ iterator_range->long double ][ 108 ][ 147 ][ !!! *41* !!! ][ 46 ]] + [[ iterator_range->array ][ !!! *<1* !!! ][ 109 ][ 22 ][ 15 ]] + [[ iterator_range->string ][ !!! *8* !!! ][ 122 ][ 29 ][ --- ]] + [[ iterator_range->container::string ][ !!! *3* !!! ][ 117 ][ 23 ][ --- ]] + [[ array->char ][ !!! *<1* !!! ][ 98 ][ 10 ][ 9 ]] + [[ array->signed char ][ !!! *<1* !!! ][ 99 ][ 9 ][ 12 ]] + [[ array->unsigned char ][ !!! *<1* !!! ][ 102 ][ 9 ][ 12 ]] + [[ array->int ][ !!! *6* !!! ][ 119 ][ 23 ][ 23 ]] + [[ array->short ][ !!! *6* !!! ][ 111 ][ 21 ][ 26 ]] + [[ array->long int ][ !!! *7* !!! ][ 115 ][ 20 ][ 28 ]] + [[ array->long long ][ !!! *9* !!! ][ 110 ][ 21 ][ 26 ]] + [[ array->unsigned int ][ !!! *6* !!! ][ 115 ][ 22 ][ 23 ]] + [[ array->unsigned short ][ !!! *6* !!! ][ 115 ][ 19 ][ 23 ]] + [[ array->unsigned long int ][ !!! *7* !!! ][ 118 ][ 23 ][ 23 ]] + [[ array->unsigned long long ][ !!! *7* !!! ][ 109 ][ 20 ][ 24 ]] + [[ array->float ][ !!! *12* !!! ][ 160 ][ 53 ][ 38 ]] + [[ array->double ][ !!! *11* !!! ][ 147 ][ 57 ][ 41 ]] + [[ array->long double ][ 109 ][ 154 ][ 59 ][ !!! *42* !!! ]] + [[ array->array ][ !!! *1* !!! ][ 105 ][ 19 ][ 14 ]] + [[ array->string ][ !!! *8* !!! ][ 129 ][ 26 ][ --- ]] + [[ array->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 ][ !!! *<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 ][ !!! *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 ][ !!! *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 ][ !!! *1* !!! ][ 107 ][ 24 ][ 12 ]] + [[ signed char*->string ][ !!! *8* !!! ][ 122 ][ 28 ][ --- ]] + [[ signed char*->container::string ][ !!! *4* !!! ][ 122 ][ 23 ][ --- ]] + [[ iterator_range->char ][ !!! *<1* !!! ][ 103 ][ 13 ][ 10 ]] + [[ iterator_range->signed char ][ !!! *<1* !!! ][ 103 ][ 13 ][ 10 ]] + [[ iterator_range->unsigned char ][ !!! *<1* !!! ][ 104 ][ 14 ][ 10 ]] + [[ iterator_range->int ][ !!! *6* !!! ][ 115 ][ 23 ][ 24 ]] + [[ iterator_range->short ][ !!! *7* !!! ][ 111 ][ 21 ][ 24 ]] + [[ iterator_range->long int ][ !!! *7* !!! ][ 108 ][ 21 ][ 23 ]] + [[ iterator_range->long long ][ !!! *7* !!! ][ 114 ][ 24 ][ 23 ]] + [[ iterator_range->unsigned int ][ !!! *6* !!! ][ 111 ][ 22 ][ 23 ]] + [[ iterator_range->unsigned short ][ !!! *5* !!! ][ 114 ][ 20 ][ 23 ]] + [[ iterator_range->unsigned long int ][ !!! *7* !!! ][ 119 ][ 25 ][ 24 ]] + [[ iterator_range->unsigned long long ][ !!! *7* !!! ][ 110 ][ 20 ][ 24 ]] + [[ iterator_range->float ][ !!! *15* !!! ][ 148 ][ 38 ][ 40 ]] + [[ iterator_range->double ][ !!! *10* !!! ][ 146 ][ 41 ][ 40 ]] + [[ iterator_range->long double ][ 103 ][ 138 ][ !!! *39* !!! ][ 42 ]] + [[ iterator_range->array ][ !!! *<1* !!! ][ 109 ][ 22 ][ 13 ]] + [[ iterator_range->string ][ !!! *7* !!! ][ 121 ][ 32 ][ --- ]] + [[ iterator_range->container::string ][ !!! *3* !!! ][ 120 ][ 24 ][ --- ]] + [[ array->char ][ !!! *<1* !!! ][ 102 ][ 9 ][ 9 ]] + [[ array->signed char ][ !!! *<1* !!! ][ 97 ][ 9 ][ 10 ]] + [[ array->unsigned char ][ !!! *<1* !!! ][ 99 ][ 9 ][ 10 ]] + [[ array->int ][ !!! *7* !!! ][ 114 ][ 22 ][ 23 ]] + [[ array->short ][ !!! *6* !!! ][ 116 ][ 21 ][ 23 ]] + [[ array->long int ][ !!! *7* !!! ][ 109 ][ 20 ][ 23 ]] + [[ array->long long ][ !!! *7* !!! ][ 114 ][ 21 ][ 23 ]] + [[ array->unsigned int ][ !!! *7* !!! ][ 119 ][ 20 ][ 25 ]] + [[ array->unsigned short ][ !!! *6* !!! ][ 120 ][ 20 ][ 23 ]] + [[ array->unsigned long int ][ !!! *7* !!! ][ 113 ][ 20 ][ 21 ]] + [[ array->unsigned long long ][ !!! *7* !!! ][ 112 ][ 20 ][ 24 ]] + [[ array->float ][ !!! *16* !!! ][ 155 ][ 57 ][ 38 ]] + [[ array->double ][ !!! *11* !!! ][ 152 ][ 59 ][ 42 ]] + [[ array->long double ][ 107 ][ 152 ][ 60 ][ !!! *41* !!! ]] + [[ array->array ][ !!! *1* !!! ][ 111 ][ 20 ][ 12 ]] + [[ array->string ][ !!! *8* !!! ][ 123 ][ 36 ][ --- ]] + [[ array->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 ][ !!! *<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 ][ !!! *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 ][ !!! *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 ][ !!! *1* !!! ][ 117 ][ 20 ][ 12 ]] [[ signed char*->string ][ !!! *8* !!! ][ 127 ][ 28 ][ --- ]] - [[ signed char*->container::string ][ !!! *4* !!! ][ 124 ][ 27 ][ --- ]] - [[ iterator_range->char ][ !!! *<1* !!! ][ 103 ][ 13 ][ 8 ]] - [[ iterator_range->signed char ][ !!! *<1* !!! ][ 107 ][ 13 ][ 9 ]] - [[ iterator_range->unsigned char ][ !!! *<1* !!! ][ 121 ][ 26 ][ 13 ]] - [[ iterator_range->int ][ !!! *6* !!! ][ 165 ][ 33 ][ 23 ]] - [[ iterator_range->short ][ !!! *8* !!! ][ 175 ][ 34 ][ 29 ]] - [[ iterator_range->long int ][ !!! *14* !!! ][ 160 ][ 33 ][ 23 ]] - [[ iterator_range->long long ][ !!! *10* !!! ][ 199 ][ 35 ][ 28 ]] - [[ iterator_range->unsigned int ][ !!! *6* !!! ][ 131 ][ 24 ][ 16 ]] - [[ iterator_range->unsigned short ][ !!! *7* !!! ][ 110 ][ 22 ][ 16 ]] - [[ iterator_range->unsigned long int ][ !!! *7* !!! ][ 111 ][ 22 ][ 14 ]] - [[ iterator_range->unsigned long long ][ !!! *8* !!! ][ 115 ][ 24 ][ 15 ]] - [[ iterator_range->float ][ !!! *13* !!! ][ 134 ][ 40 ][ 33 ]] - [[ iterator_range->double ][ !!! *15* !!! ][ 140 ][ 59 ][ 41 ]] - [[ iterator_range->long double ][ 131 ][ 146 ][ 53 ][ !!! *38* !!! ]] - [[ iterator_range->string ][ !!! *9* !!! ][ 121 ][ 31 ][ --- ]] - [[ iterator_range->container::string ][ !!! *4* !!! ][ 115 ][ 25 ][ --- ]] - [[ int->int ][ !!! *<1* !!! ][ 113 ][ 25 ][ --- ]] - [[ float->double ][ !!! *<1* !!! ][ 234 ][ 117 ][ --- ]] - [[ char->signed char ][ !!! *<1* !!! ][ 97 ][ 9 ][ --- ]] + [[ signed char*->container::string ][ !!! *4* !!! ][ 112 ][ 27 ][ --- ]] + [[ iterator_range->char ][ !!! *<1* !!! ][ 103 ][ 14 ][ 9 ]] + [[ iterator_range->signed char ][ !!! *<1* !!! ][ 104 ][ 16 ][ 10 ]] + [[ iterator_range->unsigned char ][ !!! *<1* !!! ][ 103 ][ 16 ][ 10 ]] + [[ iterator_range->int ][ !!! *6* !!! ][ 121 ][ 22 ][ 21 ]] + [[ iterator_range->short ][ !!! *7* !!! ][ 112 ][ 23 ][ 23 ]] + [[ iterator_range->long int ][ !!! *7* !!! ][ 115 ][ 24 ][ 23 ]] + [[ iterator_range->long long ][ !!! *7* !!! ][ 113 ][ 24 ][ 23 ]] + [[ iterator_range->unsigned int ][ !!! *6* !!! ][ 117 ][ 26 ][ 23 ]] + [[ iterator_range->unsigned short ][ !!! *5* !!! ][ 120 ][ 20 ][ 23 ]] + [[ iterator_range->unsigned long int ][ !!! *7* !!! ][ 124 ][ 28 ][ 21 ]] + [[ iterator_range->unsigned long long ][ !!! *7* !!! ][ 113 ][ 22 ][ 21 ]] + [[ iterator_range->float ][ !!! *11* !!! ][ 190 ][ 58 ][ 63 ]] + [[ iterator_range->double ][ !!! *20* !!! ][ 194 ][ 44 ][ 39 ]] + [[ iterator_range->long double ][ 116 ][ 145 ][ 46 ][ !!! *44* !!! ]] + [[ iterator_range->array ][ !!! *<1* !!! ][ 116 ][ 23 ][ 15 ]] + [[ iterator_range->string ][ !!! *7* !!! ][ 127 ][ 33 ][ --- ]] + [[ iterator_range->container::string ][ !!! *3* !!! ][ 112 ][ 24 ][ --- ]] + [[ array->char ][ !!! *<1* !!! ][ 98 ][ 11 ][ 10 ]] + [[ array->signed char ][ !!! *<1* !!! ][ 99 ][ 12 ][ 15 ]] + [[ array->unsigned char ][ !!! *<1* !!! ][ 100 ][ 11 ][ 10 ]] + [[ array->int ][ !!! *6* !!! ][ 114 ][ 27 ][ 22 ]] + [[ array->short ][ !!! *5* !!! ][ 113 ][ 23 ][ 23 ]] + [[ array->long int ][ !!! *7* !!! ][ 118 ][ 22 ][ 23 ]] + [[ array->long long ][ !!! *7* !!! ][ 114 ][ 26 ][ 23 ]] + [[ array->unsigned int ][ !!! *6* !!! ][ 113 ][ 27 ][ 23 ]] + [[ array->unsigned short ][ !!! *5* !!! ][ 124 ][ 21 ][ 23 ]] + [[ array->unsigned long int ][ !!! *7* !!! ][ 116 ][ 23 ][ 21 ]] + [[ array->unsigned long long ][ !!! *7* !!! ][ 115 ][ 22 ][ 21 ]] + [[ array->float ][ !!! *11* !!! ][ 162 ][ 58 ][ 36 ]] + [[ array->double ][ !!! *13* !!! ][ 155 ][ 54 ][ 44 ]] + [[ array->long double ][ 111 ][ 149 ][ 55 ][ !!! *42* !!! ]] + [[ array->array ][ !!! *1* !!! ][ 114 ][ 18 ][ 14 ]] + [[ array->string ][ !!! *7* !!! ][ 129 ][ 29 ][ --- ]] + [[ array->container::string ][ !!! *3* !!! ][ 113 ][ 26 ][ --- ]] + [[ int->int ][ !!! *<1* !!! ][ 114 ][ 25 ][ --- ]] + [[ float->double ][ !!! *<1* !!! ][ 236 ][ 121 ][ --- ]] + [[ char->signed char ][ !!! *<1* !!! ][ 97 ][ 8 ][ --- ]] ] [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 ][ !!! *<1* !!! ][ 100 ][ 13 ][ 8 ]] - [[ iterator_range->signed char ][ !!! *<1* !!! ][ 98 ][ 14 ][ 9 ]] - [[ iterator_range->unsigned char ][ !!! *<1* !!! ][ 99 ][ 12 ][ 10 ]] - [[ iterator_range->int ][ !!! *6* !!! ][ 108 ][ 21 ][ 16 ]] - [[ iterator_range->short ][ !!! *5* !!! ][ 110 ][ 22 ][ 17 ]] - [[ iterator_range->long int ][ !!! *7* !!! ][ 107 ][ 22 ][ 15 ]] - [[ iterator_range->long long ][ !!! *7* !!! ][ 110 ][ 27 ][ 15 ]] - [[ iterator_range->unsigned int ][ !!! *6* !!! ][ 107 ][ 24 ][ 15 ]] - [[ iterator_range->unsigned short ][ !!! *5* !!! ][ 106 ][ 21 ][ 15 ]] - [[ iterator_range->unsigned long int ][ !!! *7* !!! ][ 110 ][ 21 ][ 16 ]] - [[ iterator_range->unsigned long long ][ !!! *7* !!! ][ 109 ][ 23 ][ 16 ]] - [[ iterator_range->float ][ !!! *11* !!! ][ 137 ][ 46 ][ 33 ]] - [[ iterator_range->double ][ !!! *11* !!! ][ 131 ][ 50 ][ 33 ]] - [[ iterator_range->long double ][ 107 ][ 136 ][ 44 ][ !!! *39* !!! ]] - [[ iterator_range->string ][ !!! *8* !!! ][ 117 ][ 32 ][ --- ]] - [[ iterator_range->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 ][ !!! *<1* !!! ][ 103 ][ 12 ][ 8 ]] - [[ iterator_range->signed char ][ !!! *<1* !!! ][ 101 ][ 13 ][ 9 ]] - [[ iterator_range->unsigned char ][ !!! *<1* !!! ][ 103 ][ 13 ][ 10 ]] - [[ iterator_range->int ][ !!! *7* !!! ][ 113 ][ 26 ][ 14 ]] - [[ iterator_range->short ][ !!! *5* !!! ][ 115 ][ 21 ][ 16 ]] - [[ iterator_range->long int ][ !!! *7* !!! ][ 115 ][ 22 ][ 15 ]] - [[ iterator_range->long long ][ !!! *7* !!! ][ 116 ][ 25 ][ 16 ]] - [[ iterator_range->unsigned int ][ !!! *6* !!! ][ 115 ][ 24 ][ 23 ]] - [[ iterator_range->unsigned short ][ !!! *5* !!! ][ 113 ][ 22 ][ 16 ]] - [[ iterator_range->unsigned long int ][ !!! *7* !!! ][ 117 ][ 20 ][ 16 ]] - [[ iterator_range->unsigned long long ][ !!! *7* !!! ][ 114 ][ 21 ][ 16 ]] - [[ iterator_range->float ][ !!! *11* !!! ][ 145 ][ 51 ][ 34 ]] - [[ iterator_range->double ][ !!! *11* !!! ][ 139 ][ 53 ][ 35 ]] - [[ iterator_range->long double ][ 109 ][ 147 ][ 44 ][ !!! *38* !!! ]] - [[ iterator_range->string ][ !!! *9* !!! ][ 123 ][ 36 ][ --- ]] - [[ iterator_range->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 ][ !!! *<1* !!! ][ 98 ][ 13 ][ 8 ]] - [[ iterator_range->signed char ][ !!! *<1* !!! ][ 98 ][ 15 ][ 9 ]] - [[ iterator_range->unsigned char ][ !!! *<1* !!! ][ 97 ][ 15 ][ 9 ]] - [[ iterator_range->int ][ !!! *6* !!! ][ 107 ][ 27 ][ 14 ]] - [[ iterator_range->short ][ !!! *5* !!! ][ 109 ][ 23 ][ 14 ]] - [[ iterator_range->long int ][ !!! *7* !!! ][ 109 ][ 22 ][ 14 ]] - [[ iterator_range->long long ][ !!! *7* !!! ][ 107 ][ 24 ][ 14 ]] - [[ iterator_range->unsigned int ][ !!! *6* !!! ][ 120 ][ 23 ][ 14 ]] - [[ iterator_range->unsigned short ][ !!! *5* !!! ][ 104 ][ 21 ][ 17 ]] - [[ iterator_range->unsigned long int ][ !!! *8* !!! ][ 108 ][ 25 ][ 16 ]] - [[ iterator_range->unsigned long long ][ !!! *7* !!! ][ 106 ][ 25 ][ 15 ]] - [[ iterator_range->float ][ !!! *13* !!! ][ 132 ][ 41 ][ 32 ]] - [[ iterator_range->double ][ !!! *12* !!! ][ 136 ][ 45 ][ 32 ]] - [[ iterator_range->long double ][ 113 ][ 138 ][ 50 ][ !!! *36* !!! ]] - [[ iterator_range->string ][ !!! *7* !!! ][ 114 ][ 33 ][ --- ]] - [[ iterator_range->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] diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index 3e2e53f..c9d4a59 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -69,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 @@ -134,10 +134,16 @@ namespace boost } } // namespace boost -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(__SUNPRO_CC) +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(__SUNPRO_CC) && !defined(__PGIC__) #include #include + +#if !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY) +#include +#endif + +#include #include #include #include @@ -168,13 +174,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 { @@ -224,42 +230,68 @@ namespace boost { typedef char type; }; - template + template struct stream_char { typedef BOOST_DEDUCED_TYPENAME stream_char::type type; }; - template + template struct stream_char { typedef BOOST_DEDUCED_TYPENAME stream_char::type type; }; - template + template struct stream_char > { typedef BOOST_DEDUCED_TYPENAME stream_char::type type; }; - - template + + template struct stream_char > { typedef BOOST_DEDUCED_TYPENAME stream_char::type type; }; - template + template struct stream_char< std::basic_string > { typedef CharT type; }; - template + template struct stream_char< ::boost::container::basic_string > { typedef CharT type; }; + template + struct stream_char > + { + typedef BOOST_DEDUCED_TYPENAME stream_char::type type; + }; + + template + struct stream_char > + { + typedef BOOST_DEDUCED_TYPENAME stream_char::type type; + }; + +#if !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY) + template + struct stream_char > + { + typedef BOOST_DEDUCED_TYPENAME stream_char::type type; + }; + + template + struct stream_char > + { + typedef BOOST_DEDUCED_TYPENAME stream_char::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 @@ -430,7 +462,7 @@ namespace boost { // -1.23456789e-123456 // ^ sign // ^ leading digit - // ^ decimal point + // ^ decimal point // ^^^^^^^^ lcast_precision::value // ^ "e" // ^ exponent sign @@ -1259,7 +1291,6 @@ namespace boost { return true; } -#ifndef BOOST_LCAST_NO_WCHAR_T template bool shl_char_array(T const* str) { @@ -1268,7 +1299,13 @@ namespace boost { "Use boost::locale instead" ); return shl_input_streamable(str); } -#endif + + bool shl_char_array_limited(CharT const* str, std::size_t max_size) + { + start = const_cast(str); + finish = std::find(start, start + max_size, static_cast(0)); + return true; + } template bool shl_input_streamable(InputStreamable& input) @@ -1403,14 +1440,14 @@ namespace boost { { start = rng.begin(); finish = rng.end(); - return true; + return true; } - + bool operator<<(const iterator_range& rng) { start = const_cast(rng.begin()); finish = const_cast(rng.end()); - return true; + return true; } bool operator<<(const iterator_range& rng) @@ -1494,8 +1531,58 @@ namespace boost { return shl_real_type(static_cast(val), start, finish); #endif } + + template + bool operator<<(boost::array const& input) + { return shl_char_array_limited(input.begin(), N); } - template + template + bool operator<<(boost::array const& input) + { return ((*this) << reinterpret_cast const& >(input)); } + + template + bool operator<<(boost::array const& input) + { return ((*this) << reinterpret_cast const& >(input)); } + + template + bool operator<<(boost::array const& input) + { return shl_char_array_limited(input.begin(), N); } + + template + bool operator<<(boost::array const& input) + { return ((*this) << reinterpret_cast const& >(input)); } + + template + bool operator<<(boost::array const& input) + { return ((*this) << reinterpret_cast const& >(input)); } + +#if !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY) + template + bool operator<<(std::array const& input) + { return shl_char_array_limited(input.begin(), N); } + + template + bool operator<<(std::array const& input) + { return ((*this) << reinterpret_cast const& >(input)); } + + template + bool operator<<(std::array const& input) + { return ((*this) << reinterpret_cast const& >(input)); } + + template + bool operator<<(std::array const& input) + { return shl_char_array_limited(input.begin(), N); } + + template + bool operator<<(std::array const& input) + { return ((*this) << reinterpret_cast const& >(input)); } + + template + bool operator<<(std::array const& input) + { return ((*this) << reinterpret_cast const& >(input)); } +#endif // !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY) + + template bool operator<<(const InStreamable& input) { return shl_input_streamable(input); } /************************************ HELPER FUNCTIONS FOR OPERATORS >> ( ... ) ********************************/ @@ -1674,6 +1761,70 @@ namespace boost { template bool operator>>(::boost::container::basic_string& str) { str.assign(start, finish); return true; } + + private: + template + bool shr_std_array(ArrayT& output, boost::mpl::bool_ /*is_T_char_tag*/) + { + 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) = static_cast(0); + return true; + } + + template + bool shr_std_array(ArrayT& output, boost::mpl::bool_ /*is_T_char_tag*/) + { + return shr_using_base_class(output); // Array consist of non character types or unmatching character type + } + public: + + template + bool operator>>(boost::array& output) + { + typedef boost::mpl::bool_ tag_type; + return shr_std_array(output, tag_type()); + } + + template + bool operator>>(boost::array& output) + { + return ((*this) >> reinterpret_cast& >(output)); + } + + template + bool operator>>(boost::array& output) + { + return ((*this) >> reinterpret_cast& >(output)); + } + +#if !defined(BOOST_NO_CXX11_HDR_ARRAY) && defined(BOOST_HAS_TR1_ARRAY) + template + bool operator>>(std::array& output) + { + typedef boost::mpl::bool_ tag_type; + return shr_std_array(output, tag_type()); + } + + template + bool operator>>(std::array& output) + { + return ((*this) >> reinterpret_cast& >(output)); + } + + template + bool operator>>(std::array& in) + { + return ((*this) >> reinterpret_cast& >(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; @@ -1857,11 +2008,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::shl_real_type(...) template - struct is_this_float_conversion_optimized + struct is_this_float_conversion_optimized { typedef ::boost::type_traits::ice_and< ::boost::is_float::value, @@ -1937,11 +2088,6 @@ namespace boost { "Your compiler does not have full support for char32_t" ); #endif - typedef detail::lcast_src_length 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, Source >::type traits; @@ -1959,20 +2105,29 @@ namespace boost { ::boost::detail::is_char_or_wchar::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 interpreter_type; - detail::lexical_stream_limited_src - interpreter(buf, buf + src_len); + typedef detail::lcast_src_length 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); - Target result; // Disabling ADL, by directly specifying operators. if(!(interpreter.operator <<(arg) && interpreter.operator >>(result))) BOOST_LCAST_THROW_BAD_CAST(Source, Target); + return result; } }; @@ -2252,10 +2407,10 @@ namespace boost { template Target lexical_cast(Source arg) { - typedef typename detail::widest_char< - BOOST_DEDUCED_TYPENAME detail::stream_char::type - , BOOST_DEDUCED_TYPENAME detail::stream_char::type - >::type char_type; + typedef typename detail::widest_char< + BOOST_DEDUCED_TYPENAME detail::stream_char::type + , BOOST_DEDUCED_TYPENAME detail::stream_char::type + >::type char_type; typedef std::char_traits traits; detail::lexical_stream interpreter; diff --git a/lexical_cast_test.cpp b/lexical_cast_test.cpp index 844ee71..e7adc86 100644 --- a/lexical_cast_test.cpp +++ b/lexical_cast_test.cpp @@ -4,7 +4,7 @@ // // Copyright Terje Sletteb and Kevlin Henney, 2005. // Copyright Alexander Nasonov, 2006. -// Copyright Antony Polukhin, 2011. +// Copyright Antony Polukhin, 2011-2012. // // Distributed under the Boost // Software License, Version 1.0. (See accompanying file @@ -57,13 +57,6 @@ struct my_allocator : std::allocator { }; -// 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(); @@ -80,18 +73,6 @@ void test_conversion_from_wstring(); void test_conversion_to_wstring(); void test_bad_lexical_cast(); void test_no_whitespace_stripping(); -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(); @@ -107,7 +88,6 @@ void test_char16_conversions(); void test_char32_conversions(); #endif - unit_test::test_suite *init_unit_test_suite(int, char *[]) { unit_test::test_suite *suite = @@ -128,18 +108,6 @@ unit_test::test_suite *init_unit_test_suite(int, char *[]) #endif suite->add(BOOST_TEST_CASE(test_bad_lexical_cast)); suite->add(BOOST_TEST_CASE(test_no_whitespace_stripping)); - suite->add(BOOST_TEST_CASE(&test_conversion_from_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)); @@ -399,6 +367,7 @@ void test_conversion_to_wchar_t() BOOST_CHECK_THROW( lexical_cast(std::wstring(L"Test")), bad_lexical_cast); #endif + BOOST_CHECK(true); } void test_conversion_from_wstring() @@ -417,6 +386,7 @@ void test_conversion_from_wstring() BOOST_CHECK_THROW( lexical_cast(std::wstring(L"Test")), bad_lexical_cast); #endif + BOOST_CHECK(true); } void test_conversion_to_wstring() @@ -441,6 +411,7 @@ void test_conversion_to_wstring() BOOST_CHECK(L" " == lexical_cast(std::wstring(L" "))); BOOST_CHECK(L"" == lexical_cast(std::wstring(L""))); #endif + BOOST_CHECK(true); } void test_bad_lexical_cast() @@ -464,444 +435,6 @@ void test_no_whitespace_stripping() BOOST_CHECK_THROW(lexical_cast("123 "), bad_lexical_cast); } -// Replace "-,999" with "-999". -template -std::basic_string to_str_gcc_workaround(std::basic_string str) -{ - std::locale loc; - std::numpunct const& np = BOOST_USE_FACET(std::numpunct, loc); - std::ctype const& ct = BOOST_USE_FACET(std::ctype, 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 -std::basic_string to_str(T t) -{ - std::basic_ostringstream o; - o << t; - return to_str_gcc_workaround(o.str()); -} - -template -void test_conversion_from_integral_to_char(CharT zero) -{ - BOOST_CHECK(lexical_cast(static_cast(0)) == zero + 0); - BOOST_CHECK(lexical_cast(static_cast(1)) == zero + 1); - BOOST_CHECK(lexical_cast(static_cast(2)) == zero + 2); - BOOST_CHECK(lexical_cast(static_cast(3)) == zero + 3); - BOOST_CHECK(lexical_cast(static_cast(4)) == zero + 4); - BOOST_CHECK(lexical_cast(static_cast(5)) == zero + 5); - BOOST_CHECK(lexical_cast(static_cast(6)) == zero + 6); - BOOST_CHECK(lexical_cast(static_cast(7)) == zero + 7); - BOOST_CHECK(lexical_cast(static_cast(8)) == zero + 8); - BOOST_CHECK(lexical_cast(static_cast(9)) == zero + 9); - - BOOST_CHECK_THROW(lexical_cast(static_cast(10)), bad_lexical_cast); - - T t = (std::numeric_limits::max)(); - BOOST_CHECK_THROW(lexical_cast(t), bad_lexical_cast); -} - -template -void test_conversion_from_char_to_integral(CharT zero) -{ - BOOST_CHECK(lexical_cast( static_cast(zero + 0)) == static_cast(0) ); - BOOST_CHECK(lexical_cast( static_cast(zero + 1)) == static_cast(1) ); - BOOST_CHECK(lexical_cast( static_cast(zero + 2)) == static_cast(2) ); - BOOST_CHECK(lexical_cast( static_cast(zero + 3)) == static_cast(3) ); - BOOST_CHECK(lexical_cast( static_cast(zero + 4)) == static_cast(4) ); - BOOST_CHECK(lexical_cast( static_cast(zero + 5)) == static_cast(5) ); - BOOST_CHECK(lexical_cast( static_cast(zero + 6)) == static_cast(6) ); - BOOST_CHECK(lexical_cast( static_cast(zero + 7)) == static_cast(7) ); - BOOST_CHECK(lexical_cast( static_cast(zero + 8)) == static_cast(8) ); - BOOST_CHECK(lexical_cast( static_cast(zero + 9)) == static_cast(9) ); - - BOOST_CHECK_THROW(lexical_cast( static_cast(zero + 10)), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast( static_cast(zero - 1)), bad_lexical_cast); -} - -template -void test_conversion_from_integral_to_integral() -{ - T t = 0; - BOOST_CHECK(lexical_cast(t) == t); - - // Next two variables are used to supress warnings. - int st = 32767; unsigned int ut = st; - t = st; - BOOST_CHECK(lexical_cast(t) == st); - BOOST_CHECK(lexical_cast(t) == ut); - BOOST_CHECK(lexical_cast(t) == st); - BOOST_CHECK(lexical_cast(t) == ut); - BOOST_CHECK(lexical_cast(t) == st); - BOOST_CHECK(lexical_cast(t) == ut); - - t = (std::numeric_limits::max)(); - BOOST_CHECK(lexical_cast(t) == t); - - t = (std::numeric_limits::min)(); - BOOST_CHECK(lexical_cast(t) == t); -} - -template -void test_conversion_from_integral_to_string(CharT) -{ - typedef std::numeric_limits limits; - typedef std::basic_string string_type; - - T t; - - t = (limits::min)(); - BOOST_CHECK(lexical_cast(t) == to_str(t)); - - t = (limits::max)(); - BOOST_CHECK(lexical_cast(t) == to_str(t)); - - if(limits::digits <= 16 && lcast_test_small_integral_types_completely) - // min and max have already been tested. - for(t = 1 + (limits::min)(); t != (limits::max)(); ++t) - BOOST_CHECK(lexical_cast(t) == to_str(t)); - else - { - T const min_val = (limits::min)(); - T const max_val = (limits::max)(); - T const half_max_val = max_val / 2; - T const cnt = lcast_integral_test_counter; // to supress warnings - unsigned int const counter = cnt < half_max_val ? cnt : half_max_val; - - unsigned int i; - - // Test values around min: - t = min_val; - for(i = 0; i < counter; ++i, ++t) - BOOST_CHECK(lexical_cast(t) == to_str(t)); - - // Test values around max: - t = max_val; - for(i = 0; i < counter; ++i, --t) - BOOST_CHECK(lexical_cast(t) == to_str(t)); - - // Test values around zero: - if(limits::is_signed) - for(t = static_cast(-counter); t < static_cast(counter); ++t) - BOOST_CHECK(lexical_cast(t) == to_str(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(t)); - } - } -} - -template -void test_conversion_from_string_to_integral(CharT) -{ - typedef std::numeric_limits limits; - typedef std::basic_string string_type; - - string_type s; - string_type const zero = to_str(0); - string_type const nine = to_str(9); - T const min_val = (limits::min)(); - T const max_val = (limits::max)(); - - s = to_str(min_val); - BOOST_CHECK_EQUAL(lexical_cast(s), min_val); - if(limits::is_signed) - { - BOOST_CHECK_THROW(lexical_cast(s + zero), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(s + nine), bad_lexical_cast); - } - - s = to_str(max_val); - BOOST_CHECK_EQUAL(lexical_cast(s), max_val); - { - BOOST_CHECK_THROW(lexical_cast(s + zero), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(s + nine), bad_lexical_cast); - - s = to_str(max_val); - for (int i =1; i <=10; ++i) { - s[s.size()-1] += 1; - BOOST_CHECK_THROW(lexical_cast( s ), bad_lexical_cast); - } - - s = to_str(max_val); - std::locale loc; - typedef std::numpunct numpunct; - if ( BOOST_USE_FACET(numpunct, loc).grouping().empty() ) { - // Following tests work well for locale C - BOOST_CHECK_EQUAL(lexical_cast(to_str(0)+s), max_val); - BOOST_CHECK_EQUAL(lexical_cast(to_str(0)+to_str(0)+s), max_val); - BOOST_CHECK_EQUAL(lexical_cast(to_str(0)+to_str(0)+to_str(0)+s), max_val); - } - - for (int i =1; i <=256; ++i) { - BOOST_CHECK_THROW(lexical_cast( to_str(i)+s ), bad_lexical_cast); - } - - typedef BOOST_DEDUCED_TYPENAME boost::integral_promotion::type promoted; - if ( !(boost::is_same::value) ) - { - promoted prom = max_val; - s = to_str(max_val); - for (int i =1; i <=256; ++i) { - BOOST_CHECK_THROW(lexical_cast( to_str(prom+i) ), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast( to_str(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(to_str(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(to_str(t)) == t); - - // Test values around max: - t = max_val; - for(i = 0; i < counter; ++i, --t) - BOOST_CHECK(lexical_cast(to_str(t)) == t); - - // Test values around zero: - if(limits::is_signed) - for(t = static_cast(-counter); t < static_cast(counter); ++t) - BOOST_CHECK(lexical_cast(to_str(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(to_str(t)) == t); - } - } -} - -template -void test_conversion_from_to_integral_for_locale() -{ - std::locale current_locale; - typedef std::numpunct numpunct; - numpunct const& np = BOOST_USE_FACET(numpunct, current_locale); - if ( !np.grouping().empty() ) - { - BOOST_CHECK_THROW( - lexical_cast( std::string("100") + np.thousands_sep() + np.thousands_sep() + "0" ) - , bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast( std::string("100") + np.thousands_sep() ), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast( 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("30000") == static_cast(30000) ); - } - - test_conversion_from_integral_to_integral(); - test_conversion_from_integral_to_string('0'); - test_conversion_from_string_to_integral('0'); -#if !defined(BOOST_LCAST_NO_WCHAR_T) - test_conversion_from_integral_to_string(L'0'); - test_conversion_from_string_to_integral(L'0'); -#endif -} - -struct restore_oldloc -{ - std::locale oldloc; - ~restore_oldloc() { std::locale::global(oldloc); } -}; - -template -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(zero); - test_conversion_from_char_to_integral(zero); - test_conversion_from_integral_to_char(szero); - test_conversion_from_char_to_integral(szero); - test_conversion_from_integral_to_char(uzero); - test_conversion_from_char_to_integral(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(wzero); - test_conversion_from_char_to_integral(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(u16zero); - test_conversion_from_char_to_integral(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(u32zero); - test_conversion_from_char_to_integral(u32zero); -#endif - - BOOST_CHECK(lexical_cast("-1") == static_cast(-1)); - BOOST_CHECK(lexical_cast("-9") == static_cast(-9)); - BOOST_CHECK(lexical_cast(-1) == static_cast(-1)); - BOOST_CHECK(lexical_cast(-9) == static_cast(-9)); - - BOOST_CHECK_THROW(lexical_cast("-1.0"), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("-9.0"), bad_lexical_cast); - BOOST_CHECK(lexical_cast(-1.0) == static_cast(-1)); - BOOST_CHECK(lexical_cast(-9.0) == static_cast(-9)); - - BOOST_CHECK(lexical_cast(static_cast(1)) == static_cast(1)); - BOOST_CHECK(lexical_cast(static_cast(9)) == static_cast(9)); - BOOST_CHECK_THROW(lexical_cast(1.1f), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(1.1), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(1.1L), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(1.0001f), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(1.0001), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(1.0001L), bad_lexical_cast); - - BOOST_CHECK(lexical_cast("+1") == static_cast(1) ); - BOOST_CHECK(lexical_cast("+9") == static_cast(9) ); - BOOST_CHECK(lexical_cast("+10") == static_cast(10) ); - BOOST_CHECK(lexical_cast("+90") == static_cast(90) ); - BOOST_CHECK_THROW(lexical_cast("++1"), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("-+9"), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("--1"), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast("+-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(must_owerflow_str), bad_lexical_cast); - BOOST_CHECK_THROW(lexical_cast(must_owerflow_negative_str), bad_lexical_cast); - - must_owerflow_str += '0'; - must_owerflow_negative_str += '0'; - } - - typedef std::numpunct 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(); - - 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(); - - 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(); -} - -void test_conversion_from_to_ushort() -{ - test_conversion_from_to_integral(); -} - -void test_conversion_from_to_int() -{ - test_conversion_from_to_integral(); -} - -void test_conversion_from_to_uint() -{ - test_conversion_from_to_integral(); -} - -void test_conversion_from_to_long() -{ - test_conversion_from_to_integral(); -} - -void test_conversion_from_to_ulong() -{ - test_conversion_from_to_integral(); -} - -void test_conversion_from_to_intmax_t() -{ - test_conversion_from_to_integral(); -} - -void test_conversion_from_to_uintmax_t() -{ - test_conversion_from_to_integral(); -} - -#if defined(BOOST_HAS_LONG_LONG) - -void test_conversion_from_to_longlong() -{ - test_conversion_from_to_integral(); -} - -void test_conversion_from_to_ulonglong() -{ - test_conversion_from_to_integral(); -} - -#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(); -} - -#endif #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION void test_traits() @@ -960,6 +493,7 @@ void test_wallocator() #endif + void test_char_types_conversions() { const char c_arr[] = "Test array of chars"; @@ -1040,3 +574,4 @@ void test_char32_conversions() } #endif + diff --git a/perf/performance_test.cpp b/perf/performance_test.cpp index 8640bc4..7fbac4f 100644 --- a/perf/performance_test.cpp +++ b/perf/performance_test.cpp @@ -13,6 +13,7 @@ #define BOOST_CHRONO_HEADER_ONLY #include + #include #include #include @@ -21,6 +22,13 @@ // File to output data std::fstream fout; +namespace boost { +inline std::istream& operator>> (std::istream& in, boost::array& res) { + in >> res.begin(); + return in; +} +} + template static inline void test_lexical(const InT& in_val) { OutT out_val = boost::lexical_cast(in_val); @@ -37,6 +45,28 @@ static inline void test_ss_constr(const InT& in_val) { if (ss.fail()) throw std::logic_error("descr"); } +template +static inline void test_ss_constr(const boost::array& 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 +static inline void test_ss_noconstr(StringStreamT& ss, const boost::array& 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 static inline void test_ss_noconstr(StringStreamT& ss, const InT& in_val) { OutT out_val; @@ -64,6 +94,12 @@ struct structure_sprintf { }; struct structure_sscanf { + template + static inline void test(BufferT* /*buffer*/, const boost::array& in_val, const char* const conv) { + OutT out_val; + sscanf(in_val.cbegin(), conv, &out_val); + } + template static inline void test(BufferT* /*buffer*/, const InT& in_val, const char* const conv) { OutT out_val; @@ -229,7 +265,7 @@ void string_like_test_set(const std::string& from) { perf_test(from + "->float", conv("1.123"), "%f"); perf_test(from + "->double", conv("1.123"), "%lf"); perf_test(from + "->long double", conv("1.123"), "%Lf"); - + perf_test, ssc_t>(from + "->array", conv("1.123"), "%s"); perf_test(from + "->string", conv("string"), "%Lf"); perf_test(from + "->container::string" @@ -268,6 +304,14 @@ struct to_iterator_range { } }; +struct to_array_50 { + boost::array operator()(const char* const c) const { + boost::array ret; + std::strcpy(ret.begin(), c); + return ret; + } +}; + int main(int argc, char** argv) { BOOST_ASSERT(argc >= 2); std::string output_path(argv[1]); @@ -310,6 +354,7 @@ int main(int argc, char** argv) { string_like_test_set("unsigned char*"); string_like_test_set("signed char*"); string_like_test_set("iterator_range"); + string_like_test_set("array"); perf_test("int->int", 100, ""); perf_test("float->double", 100.0f, ""); diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index f8ee0d3..f77a845 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -47,5 +47,7 @@ test-suite conversion gcc-4.7:-fno-exceptions ] [ run lexical_cast_iterator_range_test.cpp ] + [ run lexical_cast_arrays_test.cpp ] + [ run lexical_cast_integral_types_test.cpp ] ; diff --git a/test/implicit_cast.cpp b/test/implicit_cast.cpp index 8c3bc52..0cad067 100644 --- a/test/implicit_cast.cpp +++ b/test/implicit_cast.cpp @@ -28,7 +28,7 @@ int main() type f = check_return(boost::implicit_cast("hello")); type z = check_return(boost::implicit_cast(foo("hello"))); - + // warning supression: (void)x; (void)f; diff --git a/test/implicit_cast_fail.cpp b/test/implicit_cast_fail.cpp index 80143da..a7867a1 100644 --- a/test/implicit_cast_fail.cpp +++ b/test/implicit_cast_fail.cpp @@ -19,4 +19,6 @@ struct foo int test_main(int, char*[]) { foo x = implicit_cast("foobar"); + (void)x; // warning suppression. + return 0; } diff --git a/test/lexical_cast_arrays_test.cpp b/test/lexical_cast_arrays_test.cpp new file mode 100644 index 0000000..6aff2d9 --- /dev/null +++ b/test/lexical_cast_arrays_test.cpp @@ -0,0 +1,367 @@ +// 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 + +#include + +#include + +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