diff --git a/doc/lexical_cast.qbk b/doc/lexical_cast.qbk index 4ad8336..ffab311 100644 --- a/doc/lexical_cast.qbk +++ b/doc/lexical_cast.qbk @@ -115,6 +115,55 @@ Exception used to indicate runtime lexical_cast failure. [endsect] +[section Tuning classes for fast lexical conversions] +Because of `boost::lexical_cast` optimizations for `boost::iterator_range`, it is possibile to make very fast lexical conversions for non zero terminated strings, substrings and user-defined classes. + +Consider the following example: +`` + class example_class { + char non_zero_terminated_data[10]; + std::size_t data_length; + + public: + example_class(); + void fill_data(); + + const char* data() const { + return non_zero_terminated_data; + } + + std::size_t size() const { + return data_length; + } + }; + + inline std::ostream& operator << (std::ostream& ostr, const example_class& rhs) { + return ostr << boost::make_iterator_range(rhs.data(), rhs.data() + rhs.size()); + } +`` + +This is a good generic solution for most use cases. +But we can make it even faster for some performance critical applications. During conversion, we loose speed at: + +* `std::ostream` construction (it makes some heap allocations) +* `operator <<` (it copyies one by one all the symbols to an instance of `std::ostream`) +* `std::ostream` destruction (it makes some heap deallocations) + +We can avoid all of this, by specifieng an overload for `boost::lexical_cast`: +`` +namespace boost { + template + OutT lexical_cast(const example_class& rhs) { + return boost::lexical_cast( + boost::make_iterator_range(rhs.data(), rhs.data() + rhs.size()) + ); + } +} +`` +Now `boost::lexical_cast(example_class_instance)` conversions won't copy data and construct heavy STL stream objects. See [link boost_lexical_cast.performance Performance] section for info on `boost::iterator_range` conversion performance. +[endsect] + + [section Frequently Asked Questions] * [*Question:] Why does `lexical_cast("127")` throw `bad_lexical_cast`? @@ -175,6 +224,9 @@ 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. +* [*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] @@ -182,7 +234,8 @@ limitation of compiler options that you use. * `boost::bad_lexical_cast` exception is now globaly visible and can be catched even if code is compiled with -fvisibility=hidden. * Now it is possible to compile library with disabled exceptions. - + * Better performance, less memory usage and bugfixes for `boost::iterator_range` conversions. + * [*boost 1.49.0 :] * Restored work with typedefed wchar_t (compilation flag /Zc:wchar_t- for Visual Studio). @@ -267,364 +320,415 @@ Do not use this results to compare compilers, because tests were taken on differ [/ BEGIN of section, generated by performance measuring program ] -[section clang-linux-2.8][table:id Performance Table (clang-linux-2.8) +[section Clang version 2.9 (tags/RELEASE_29/final)] +[table:id Performance Table ( Clang version 2.9 (tags/RELEASE_29/final)) [[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] -[[ string->char ][ !!! *<1* !!! ][ 148 ][ 14 ][ 12 ]] -[[ string->signed char ][ !!! *<1* !!! ][ 97 ][ 8 ][ 7 ]] -[[ string->unsigned char ][ !!! *<1* !!! ][ 90 ][ 8 ][ 13 ]] -[[ string->int ][ !!! *4* !!! ][ 102 ][ 19 ][ 15 ]] -[[ string->short ][ !!! *4* !!! ][ 105 ][ 20 ][ 15 ]] -[[ string->long int ][ !!! *4* !!! ][ 105 ][ 19 ][ 15 ]] -[[ string->long long ][ !!! *4* !!! ][ 115 ][ 19 ][ 14 ]] -[[ string->unsigned int ][ !!! *4* !!! ][ 102 ][ 18 ][ 14 ]] -[[ string->unsigned short ][ !!! *4* !!! ][ 101 ][ 19 ][ 15 ]] -[[ string->unsigned long int ][ !!! *3* !!! ][ 107 ][ 20 ][ 14 ]] -[[ string->unsigned long long ][ !!! *3* !!! ][ 103 ][ 20 ][ 14 ]] -[[ string->bool ][ !!! *<1* !!! ][ 97 ][ 16 ][ 8 ]] -[[ string->float ][ !!! *21* !!! ][ 170 ][ 61 ][ 32 ]] -[[ string->double ][ !!! *18* !!! ][ 206 ][ 93 ][ 58 ]] -[[ string->long double ][ 135 ][ 221 ][ 94 ][ !!! *57* !!! ]] -[[ char->string ][ !!! *7* !!! ][ 100 ][ 17 ][ 13 ]] -[[ unsigned char->string ][ !!! *7* !!! ][ 99 ][ 18 ][ 16 ]] -[[ signed char->string ][ !!! *7* !!! ][ 101 ][ 17 ][ 12 ]] -[[ int->string ][ !!! *13* !!! ][ 110 ][ 23 ][ 15 ]] -[[ short->string ][ !!! *13* !!! ][ 112 ][ 24 ][ 18 ]] -[[ long int->string ][ !!! *13* !!! ][ 119 ][ 23 ][ 17 ]] -[[ long long->string ][ !!! *13* !!! ][ 110 ][ 23 ][ 18 ]] -[[ unsigned int->string ][ !!! *14* !!! ][ 113 ][ 24 ][ 17 ]] -[[ unsigned short->string ][ !!! *13* !!! ][ 108 ][ 24 ][ 17 ]] -[[ unsigned long int->string ][ !!! *13* !!! ][ 109 ][ 24 ][ 16 ]] -[[ unsigned long long->string ][ !!! *13* !!! ][ 110 ][ 23 ][ 17 ]] -[[ bool->string ][ !!! *7* !!! ][ 105 ][ 24 ][ 12 ]] -[[ float->string ][ 70 ][ 192 ][ 94 ][ !!! *49* !!! ]] -[[ double->string ][ 106 ][ 217 ][ 122 ][ !!! *76* !!! ]] -[[ long double->string ][ 120 ][ 219 ][ 123 ][ !!! *80* !!! ]] -[[ char*->char ][ !!! *2* !!! ][ 90 ][ 9 ][ 8 ]] -[[ char*->signed char ][ !!! *2* !!! ][ 87 ][ 10 ][ 7 ]] -[[ char*->unsigned char ][ !!! *3* !!! ][ 90 ][ 10 ][ 13 ]] -[[ char*->int ][ !!! *6* !!! ][ 107 ][ 21 ][ 15 ]] -[[ char*->short ][ !!! *6* !!! ][ 110 ][ 19 ][ 14 ]] -[[ char*->long int ][ !!! *6* !!! ][ 103 ][ 19 ][ 14 ]] -[[ char*->long long ][ !!! *7* !!! ][ 104 ][ 20 ][ 15 ]] -[[ char*->unsigned int ][ !!! *6* !!! ][ 101 ][ 20 ][ 15 ]] -[[ char*->unsigned short ][ !!! *7* !!! ][ 100 ][ 20 ][ 14 ]] -[[ char*->unsigned long int ][ !!! *6* !!! ][ 105 ][ 22 ][ 15 ]] -[[ char*->unsigned long long ][ !!! *7* !!! ][ 106 ][ 21 ][ 14 ]] -[[ char*->bool ][ !!! *2* !!! ][ 99 ][ 18 ][ 7 ]] -[[ char*->float ][ !!! *22* !!! ][ 159 ][ 67 ][ 33 ]] -[[ char*->double ][ !!! *20* !!! ][ 205 ][ 94 ][ 58 ]] -[[ char*->long double ][ 140 ][ 214 ][ 95 ][ !!! *58* !!! ]] -[[ unsigned char*->char ][ !!! *2* !!! ][ 92 ][ 9 ][ 7 ]] -[[ unsigned char*->signed char ][ !!! *2* !!! ][ 89 ][ 10 ][ 7 ]] -[[ unsigned char*->unsigned char ][ !!! *2* !!! ][ 89 ][ 10 ][ 14 ]] -[[ unsigned char*->int ][ !!! *6* !!! ][ 104 ][ 20 ][ 14 ]] -[[ unsigned char*->short ][ !!! *6* !!! ][ 106 ][ 21 ][ 14 ]] -[[ unsigned char*->long int ][ !!! *6* !!! ][ 105 ][ 19 ][ 14 ]] -[[ unsigned char*->long long ][ !!! *6* !!! ][ 106 ][ 20 ][ 15 ]] -[[ unsigned char*->unsigned int ][ !!! *7* !!! ][ 105 ][ 19 ][ 14 ]] -[[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 103 ][ 19 ][ 14 ]] -[[ unsigned char*->unsigned long int ][ !!! *6* !!! ][ 106 ][ 19 ][ 14 ]] -[[ unsigned char*->unsigned long long ][ !!! *6* !!! ][ 104 ][ 21 ][ 15 ]] -[[ unsigned char*->bool ][ !!! *2* !!! ][ 102 ][ 18 ][ 7 ]] -[[ unsigned char*->float ][ !!! *23* !!! ][ 160 ][ 66 ][ 32 ]] -[[ unsigned char*->double ][ !!! *20* !!! ][ 201 ][ 95 ][ 58 ]] -[[ unsigned char*->long double ][ 144 ][ 221 ][ 95 ][ !!! *60* !!! ]] -[[ unsigned char*->string ][ !!! *12* !!! ][ 104 ][ 23 ][ --- ]] -[[ signed char*->char ][ !!! *2* !!! ][ 90 ][ 9 ][ 7 ]] -[[ signed char*->signed char ][ !!! *2* !!! ][ 89 ][ 9 ][ 7 ]] -[[ signed char*->unsigned char ][ !!! *2* !!! ][ 89 ][ 10 ][ 13 ]] -[[ signed char*->int ][ !!! *6* !!! ][ 106 ][ 19 ][ 15 ]] -[[ signed char*->short ][ !!! *6* !!! ][ 107 ][ 20 ][ 15 ]] -[[ signed char*->long int ][ !!! *6* !!! ][ 103 ][ 19 ][ 14 ]] -[[ signed char*->long long ][ !!! *6* !!! ][ 103 ][ 19 ][ 14 ]] -[[ signed char*->unsigned int ][ !!! *6* !!! ][ 101 ][ 19 ][ 15 ]] -[[ signed char*->unsigned short ][ !!! *6* !!! ][ 101 ][ 19 ][ 16 ]] -[[ signed char*->unsigned long int ][ !!! *6* !!! ][ 105 ][ 22 ][ 15 ]] -[[ signed char*->unsigned long long ][ !!! *6* !!! ][ 104 ][ 21 ][ 15 ]] -[[ signed char*->bool ][ !!! *2* !!! ][ 100 ][ 18 ][ 7 ]] -[[ signed char*->float ][ !!! *23* !!! ][ 161 ][ 62 ][ 32 ]] -[[ signed char*->double ][ !!! *20* !!! ][ 207 ][ 102 ][ 57 ]] -[[ signed char*->long double ][ 144 ][ 216 ][ 96 ][ !!! *63* !!! ]] -[[ signed char*->string ][ !!! *12* !!! ][ 104 ][ 23 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 110 ][ 22 ][ --- ]] -[[ float->double ][ !!! *<1* !!! ][ 223 ][ 113 ][ --- ]] -[[ double->double ][ !!! *<1* !!! ][ 227 ][ 111 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 231 ][ 122 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 229 ][ 121 ][ --- ]] -[[ char->unsigned char ][ !!! *<1* !!! ][ 90 ][ 8 ][ --- ]] -[[ char->signed char ][ !!! *<1* !!! ][ 88 ][ 8 ][ --- ]] -[[ unsigned char->char ][ !!! *<1* !!! ][ 89 ][ 8 ][ --- ]] -[[ signed char->char ][ !!! *<1* !!! ][ 91 ][ 9 ][ --- ]] + [[ string->char ][ !!! *<1* !!! ][ 319 ][ 17 ][ 16 ]] + [[ string->signed char ][ !!! *<1* !!! ][ 192 ][ 16 ][ 9 ]] + [[ string->unsigned char ][ !!! *<1* !!! ][ 142 ][ 9 ][ 9 ]] + [[ string->int ][ !!! *7* !!! ][ 109 ][ 21 ][ 16 ]] + [[ string->short ][ !!! *6* !!! ][ 113 ][ 21 ][ 15 ]] + [[ string->long int ][ !!! *7* !!! ][ 110 ][ 22 ][ 15 ]] + [[ string->long long ][ !!! *7* !!! ][ 112 ][ 23 ][ 17 ]] + [[ string->unsigned int ][ !!! *6* !!! ][ 107 ][ 19 ][ 14 ]] + [[ string->unsigned short ][ !!! *6* !!! ][ 106 ][ 18 ][ 16 ]] + [[ string->unsigned long int ][ !!! *7* !!! ][ 108 ][ 20 ][ 15 ]] + [[ string->unsigned long long ][ !!! *7* !!! ][ 109 ][ 22 ][ 15 ]] + [[ string->float ][ !!! *14* !!! ][ 204 ][ 81 ][ 43 ]] + [[ string->double ][ !!! *24* !!! ][ 244 ][ 74 ][ 45 ]] + [[ string->long double ][ 121 ][ 170 ][ 62 ][ !!! *38* !!! ]] + [[ string->string ][ !!! *1* !!! ][ 124 ][ 25 ][ --- ]] + [[ string->container::string ][ !!! *3* !!! ][ 121 ][ 28 ][ --- ]] + [[ string->char ][ 6 ][ 115 ][ 26 ][ !!! *6* !!! ]] + [[ string->signed char ][ !!! *6* !!! ][ 115 ][ 23 ][ 21 ]] + [[ string->unsigned char ][ !!! *6* !!! ][ 113 ][ 25 ][ 22 ]] + [[ int->string ][ !!! *12* !!! ][ 128 ][ 29 ][ 19 ]] + [[ short->string ][ !!! *12* !!! ][ 128 ][ 29 ][ 21 ]] + [[ long int->string ][ !!! *12* !!! ][ 132 ][ 29 ][ 21 ]] + [[ long long->string ][ !!! *12* !!! ][ 127 ][ 29 ][ 22 ]] + [[ unsigned int->string ][ !!! *12* !!! ][ 137 ][ 33 ][ 19 ]] + [[ unsigned short->string ][ !!! *12* !!! ][ 137 ][ 31 ][ 20 ]] + [[ unsigned long int->string ][ !!! *12* !!! ][ 136 ][ 30 ][ 21 ]] + [[ unsigned long long->string ][ !!! *12* !!! ][ 128 ][ 27 ][ 23 ]] + [[ float->string ][ 51 ][ 187 ][ 82 ][ !!! *44* !!! ]] + [[ double->string ][ 56 ][ 190 ][ 83 ][ !!! *42* !!! ]] + [[ long double->string ][ 69 ][ 208 ][ 90 ][ !!! *54* !!! ]] + [[ char*->char ][ !!! *<1* !!! ][ 138 ][ 18 ][ 8 ]] + [[ char*->signed char ][ !!! *8* !!! ][ 126 ][ 10 ][ 9 ]] + [[ char*->unsigned char ][ !!! *<1* !!! ][ 98 ][ 9 ][ 9 ]] + [[ char*->int ][ !!! *8* !!! ][ 113 ][ 22 ][ 15 ]] + [[ char*->short ][ !!! *7* !!! ][ 113 ][ 22 ][ 17 ]] + [[ char*->long int ][ !!! *8* !!! ][ 111 ][ 23 ][ 15 ]] + [[ char*->long long ][ !!! *9* !!! ][ 112 ][ 24 ][ 18 ]] + [[ char*->unsigned int ][ !!! *8* !!! ][ 113 ][ 20 ][ 15 ]] + [[ char*->unsigned short ][ !!! *8* !!! ][ 113 ][ 20 ][ 15 ]] + [[ char*->unsigned long int ][ !!! *8* !!! ][ 112 ][ 21 ][ 16 ]] + [[ char*->unsigned long long ][ !!! *9* !!! ][ 110 ][ 23 ][ 14 ]] + [[ char*->float ][ !!! *14* !!! ][ 149 ][ 54 ][ 32 ]] + [[ char*->double ][ !!! *15* !!! ][ 166 ][ 59 ][ 33 ]] + [[ char*->long double ][ 122 ][ 171 ][ 63 ][ !!! *38* !!! ]] + [[ char*->string ][ !!! *7* !!! ][ 126 ][ 26 ][ --- ]] + [[ char*->container::string ][ !!! *2* !!! ][ 124 ][ 27 ][ --- ]] + [[ unsigned char*->char ][ !!! *<1* !!! ][ 99 ][ 10 ][ 8 ]] + [[ unsigned char*->signed char ][ !!! *<1* !!! ][ 102 ][ 10 ][ 9 ]] + [[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 98 ][ 10 ][ 9 ]] + [[ unsigned char*->int ][ !!! *7* !!! ][ 115 ][ 24 ][ 15 ]] + [[ unsigned char*->short ][ !!! *7* !!! ][ 115 ][ 25 ][ 17 ]] + [[ unsigned char*->long int ][ !!! *8* !!! ][ 115 ][ 22 ][ 16 ]] + [[ unsigned char*->long long ][ !!! *8* !!! ][ 116 ][ 23 ][ 16 ]] + [[ unsigned char*->unsigned int ][ !!! *8* !!! ][ 113 ][ 20 ][ 14 ]] + [[ unsigned char*->unsigned short ][ !!! *7* !!! ][ 114 ][ 21 ][ 15 ]] + [[ unsigned char*->unsigned long int ][ !!! *8* !!! ][ 114 ][ 21 ][ 14 ]] + [[ unsigned char*->unsigned long long ][ !!! *9* !!! ][ 112 ][ 23 ][ 16 ]] + [[ unsigned char*->float ][ !!! *14* !!! ][ 149 ][ 52 ][ 32 ]] + [[ unsigned char*->double ][ !!! *15* !!! ][ 165 ][ 59 ][ 33 ]] + [[ unsigned char*->long double ][ 122 ][ 172 ][ 63 ][ !!! *37* !!! ]] + [[ unsigned char*->string ][ !!! *8* !!! ][ 125 ][ 26 ][ --- ]] + [[ unsigned char*->container::string ][ !!! *4* !!! ][ 119 ][ 26 ][ --- ]] + [[ signed char*->char ][ !!! *<1* !!! ][ 98 ][ 10 ][ 8 ]] + [[ signed char*->signed char ][ !!! *<1* !!! ][ 95 ][ 10 ][ 9 ]] + [[ signed char*->unsigned char ][ !!! *<1* !!! ][ 98 ][ 9 ][ 9 ]] + [[ signed char*->int ][ !!! *8* !!! ][ 111 ][ 21 ][ 15 ]] + [[ signed char*->short ][ !!! *7* !!! ][ 114 ][ 22 ][ 16 ]] + [[ signed char*->long int ][ !!! *8* !!! ][ 113 ][ 22 ][ 17 ]] + [[ signed char*->long long ][ !!! *8* !!! ][ 116 ][ 24 ][ 17 ]] + [[ signed char*->unsigned int ][ !!! *8* !!! ][ 109 ][ 20 ][ 15 ]] + [[ signed char*->unsigned short ][ !!! *8* !!! ][ 111 ][ 20 ][ 14 ]] + [[ signed char*->unsigned long int ][ !!! *8* !!! ][ 109 ][ 22 ][ 15 ]] + [[ signed char*->unsigned long long ][ !!! *8* !!! ][ 111 ][ 23 ][ 15 ]] + [[ signed char*->float ][ !!! *14* !!! ][ 150 ][ 53 ][ 32 ]] + [[ signed char*->double ][ !!! *15* !!! ][ 168 ][ 59 ][ 30 ]] + [[ signed char*->long double ][ 123 ][ 174 ][ 62 ][ !!! *37* !!! ]] + [[ signed char*->string ][ !!! *8* !!! ][ 127 ][ 28 ][ --- ]] + [[ signed char*->container::string ][ !!! *4* !!! ][ 124 ][ 27 ][ --- ]] + [[ iterator_range->char ][ !!! *<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 ][ --- ]] ] [endsect] -[section gcc-4.4][table:id Performance Table (gcc-4.4) + +[section GNU C++ version 4.6.1] +[table:id Performance Table ( GNU C++ version 4.6.1) [[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] -[[ string->char ][ !!! *<1* !!! ][ 90 ][ 7 ][ 7 ]] -[[ string->signed char ][ !!! *<1* !!! ][ 88 ][ 7 ][ 8 ]] -[[ string->unsigned char ][ !!! *<1* !!! ][ 88 ][ 8 ][ 14 ]] -[[ string->int ][ !!! *3* !!! ][ 103 ][ 18 ][ 15 ]] -[[ string->short ][ !!! *3* !!! ][ 105 ][ 20 ][ 15 ]] -[[ string->long int ][ !!! *3* !!! ][ 101 ][ 18 ][ 16 ]] -[[ string->long long ][ !!! *3* !!! ][ 101 ][ 18 ][ 15 ]] -[[ string->unsigned int ][ !!! *3* !!! ][ 98 ][ 23 ][ 14 ]] -[[ string->unsigned short ][ !!! *3* !!! ][ 100 ][ 17 ][ 14 ]] -[[ string->unsigned long int ][ !!! *3* !!! ][ 100 ][ 21 ][ 15 ]] -[[ string->unsigned long long ][ !!! *3* !!! ][ 99 ][ 19 ][ 15 ]] -[[ string->bool ][ !!! *<1* !!! ][ 95 ][ 16 ][ 8 ]] -[[ string->float ][ !!! *13* !!! ][ 160 ][ 61 ][ 33 ]] -[[ string->double ][ !!! *14* !!! ][ 206 ][ 93 ][ 59 ]] -[[ string->long double ][ 128 ][ 217 ][ 96 ][ !!! *61* !!! ]] -[[ char->string ][ !!! *7* !!! ][ 100 ][ 17 ][ 12 ]] -[[ unsigned char->string ][ !!! *7* !!! ][ 109 ][ 17 ][ 16 ]] -[[ signed char->string ][ !!! *7* !!! ][ 99 ][ 17 ][ 12 ]] -[[ int->string ][ !!! *13* !!! ][ 110 ][ 21 ][ 15 ]] -[[ short->string ][ !!! *14* !!! ][ 110 ][ 22 ][ 17 ]] -[[ long int->string ][ !!! *14* !!! ][ 109 ][ 21 ][ 16 ]] -[[ long long->string ][ !!! *13* !!! ][ 114 ][ 20 ][ 17 ]] -[[ unsigned int->string ][ !!! *13* !!! ][ 109 ][ 23 ][ 15 ]] -[[ unsigned short->string ][ !!! *14* !!! ][ 109 ][ 23 ][ 17 ]] -[[ unsigned long int->string ][ !!! *13* !!! ][ 112 ][ 23 ][ 16 ]] -[[ unsigned long long->string ][ !!! *14* !!! ][ 109 ][ 21 ][ 17 ]] -[[ bool->string ][ !!! *7* !!! ][ 108 ][ 23 ][ 11 ]] -[[ float->string ][ 63 ][ 185 ][ 92 ][ !!! *50* !!! ]] -[[ double->string ][ 106 ][ 216 ][ 116 ][ !!! *75* !!! ]] -[[ long double->string ][ 118 ][ 219 ][ 119 ][ !!! *80* !!! ]] -[[ char*->char ][ !!! *1* !!! ][ 93 ][ 9 ][ 9 ]] -[[ char*->signed char ][ !!! *1* !!! ][ 92 ][ 9 ][ 9 ]] -[[ char*->unsigned char ][ !!! *1* !!! ][ 92 ][ 9 ][ 14 ]] -[[ char*->int ][ !!! *4* !!! ][ 107 ][ 19 ][ 15 ]] -[[ char*->short ][ !!! *5* !!! ][ 109 ][ 19 ][ 15 ]] -[[ char*->long int ][ !!! *4* !!! ][ 113 ][ 19 ][ 15 ]] -[[ char*->long long ][ !!! *4* !!! ][ 108 ][ 20 ][ 15 ]] -[[ char*->unsigned int ][ !!! *4* !!! ][ 106 ][ 19 ][ 15 ]] -[[ char*->unsigned short ][ !!! *4* !!! ][ 106 ][ 18 ][ 15 ]] -[[ char*->unsigned long int ][ !!! *4* !!! ][ 103 ][ 22 ][ 15 ]] -[[ char*->unsigned long long ][ !!! *4* !!! ][ 105 ][ 20 ][ 15 ]] -[[ char*->bool ][ !!! *1* !!! ][ 104 ][ 18 ][ 8 ]] -[[ char*->float ][ !!! *15* !!! ][ 164 ][ 62 ][ 33 ]] -[[ char*->double ][ !!! *16* !!! ][ 203 ][ 97 ][ 58 ]] -[[ char*->long double ][ 132 ][ 223 ][ 98 ][ !!! *60* !!! ]] -[[ unsigned char*->char ][ !!! *2* !!! ][ 90 ][ 9 ][ 8 ]] -[[ unsigned char*->signed char ][ !!! *2* !!! ][ 92 ][ 10 ][ 8 ]] -[[ unsigned char*->unsigned char ][ !!! *2* !!! ][ 91 ][ 9 ][ 14 ]] -[[ unsigned char*->int ][ !!! *6* !!! ][ 106 ][ 20 ][ 15 ]] -[[ unsigned char*->short ][ !!! *6* !!! ][ 106 ][ 21 ][ 15 ]] -[[ unsigned char*->long int ][ !!! *6* !!! ][ 111 ][ 19 ][ 15 ]] -[[ unsigned char*->long long ][ !!! *6* !!! ][ 107 ][ 20 ][ 15 ]] -[[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 105 ][ 19 ][ 15 ]] -[[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 103 ][ 18 ][ 15 ]] -[[ unsigned char*->unsigned long int ][ !!! *6* !!! ][ 106 ][ 22 ][ 14 ]] -[[ unsigned char*->unsigned long long ][ !!! *6* !!! ][ 105 ][ 20 ][ 14 ]] -[[ unsigned char*->bool ][ !!! *2* !!! ][ 106 ][ 18 ][ 8 ]] -[[ unsigned char*->float ][ !!! *15* !!! ][ 167 ][ 68 ][ 33 ]] -[[ unsigned char*->double ][ !!! *17* !!! ][ 203 ][ 99 ][ 58 ]] -[[ unsigned char*->long double ][ 129 ][ 216 ][ 97 ][ !!! *61* !!! ]] -[[ unsigned char*->string ][ !!! *13* !!! ][ 111 ][ 23 ][ --- ]] -[[ signed char*->char ][ !!! *2* !!! ][ 92 ][ 9 ][ 8 ]] -[[ signed char*->signed char ][ !!! *2* !!! ][ 91 ][ 9 ][ 8 ]] -[[ signed char*->unsigned char ][ !!! *2* !!! ][ 91 ][ 9 ][ 14 ]] -[[ signed char*->int ][ !!! *6* !!! ][ 107 ][ 19 ][ 15 ]] -[[ signed char*->short ][ !!! *6* !!! ][ 109 ][ 24 ][ 14 ]] -[[ signed char*->long int ][ !!! *6* !!! ][ 112 ][ 19 ][ 15 ]] -[[ signed char*->long long ][ !!! *5* !!! ][ 107 ][ 20 ][ 15 ]] -[[ signed char*->unsigned int ][ !!! *6* !!! ][ 108 ][ 20 ][ 15 ]] -[[ signed char*->unsigned short ][ !!! *6* !!! ][ 104 ][ 18 ][ 15 ]] -[[ signed char*->unsigned long int ][ !!! *6* !!! ][ 102 ][ 22 ][ 15 ]] -[[ signed char*->unsigned long long ][ !!! *6* !!! ][ 104 ][ 20 ][ 15 ]] -[[ signed char*->bool ][ !!! *2* !!! ][ 104 ][ 18 ][ 8 ]] -[[ signed char*->float ][ !!! *16* !!! ][ 165 ][ 63 ][ 33 ]] -[[ signed char*->double ][ !!! *16* !!! ][ 203 ][ 98 ][ 59 ]] -[[ signed char*->long double ][ 129 ][ 215 ][ 98 ][ !!! *61* !!! ]] -[[ signed char*->string ][ !!! *13* !!! ][ 109 ][ 21 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 109 ][ 21 ][ --- ]] -[[ float->double ][ !!! *<1* !!! ][ 221 ][ 102 ][ --- ]] -[[ double->double ][ !!! *<1* !!! ][ 223 ][ 103 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 231 ][ 115 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 231 ][ 115 ][ --- ]] -[[ char->unsigned char ][ !!! *<1* !!! ][ 92 ][ 8 ][ --- ]] -[[ char->signed char ][ !!! *<1* !!! ][ 88 ][ 8 ][ --- ]] -[[ unsigned char->char ][ !!! *<1* !!! ][ 88 ][ 7 ][ --- ]] -[[ signed char->char ][ !!! *<1* !!! ][ 89 ][ 8 ][ --- ]] + [[ string->char ][ !!! *<1* !!! ][ 140 ][ 17 ][ 13 ]] + [[ string->signed char ][ !!! *<1* !!! ][ 129 ][ 8 ][ 10 ]] + [[ string->unsigned char ][ !!! *<1* !!! ][ 91 ][ 8 ][ 10 ]] + [[ string->int ][ !!! *6* !!! ][ 110 ][ 20 ][ 14 ]] + [[ string->short ][ !!! *5* !!! ][ 106 ][ 20 ][ 14 ]] + [[ string->long int ][ !!! *7* !!! ][ 107 ][ 22 ][ 14 ]] + [[ string->long long ][ !!! *7* !!! ][ 112 ][ 21 ][ 14 ]] + [[ string->unsigned int ][ !!! *6* !!! ][ 110 ][ 20 ][ 14 ]] + [[ string->unsigned short ][ !!! *5* !!! ][ 107 ][ 18 ][ 14 ]] + [[ string->unsigned long int ][ !!! *7* !!! ][ 108 ][ 23 ][ 14 ]] + [[ string->unsigned long long ][ !!! *7* !!! ][ 108 ][ 21 ][ 14 ]] + [[ string->float ][ !!! *12* !!! ][ 154 ][ 57 ][ 32 ]] + [[ string->double ][ !!! *11* !!! ][ 151 ][ 61 ][ 33 ]] + [[ string->long double ][ 109 ][ 187 ][ 79 ][ !!! *55* !!! ]] + [[ string->string ][ !!! *2* !!! ][ 122 ][ 27 ][ --- ]] + [[ string->container::string ][ !!! *3* !!! ][ 123 ][ 22 ][ --- ]] + [[ string->char ][ !!! *7* !!! ][ 109 ][ 27 ][ 17 ]] + [[ string->signed char ][ !!! *7* !!! ][ 110 ][ 25 ][ 22 ]] + [[ string->unsigned char ][ !!! *7* !!! ][ 112 ][ 27 ][ 24 ]] + [[ int->string ][ !!! *12* !!! ][ 187 ][ 48 ][ 37 ]] + [[ short->string ][ !!! *18* !!! ][ 133 ][ 33 ][ 20 ]] + [[ long int->string ][ !!! *12* !!! ][ 129 ][ 32 ][ 21 ]] + [[ long long->string ][ !!! *12* !!! ][ 127 ][ 35 ][ 23 ]] + [[ unsigned int->string ][ !!! *15* !!! ][ 133 ][ 31 ][ 21 ]] + [[ unsigned short->string ][ !!! *12* !!! ][ 133 ][ 31 ][ 21 ]] + [[ unsigned long int->string ][ !!! *12* !!! ][ 132 ][ 31 ][ 21 ]] + [[ unsigned long long->string ][ !!! *12* !!! ][ 127 ][ 29 ][ 24 ]] + [[ float->string ][ 53 ][ 215 ][ 103 ][ !!! *40* !!! ]] + [[ double->string ][ 58 ][ 215 ][ 103 ][ !!! *41* !!! ]] + [[ long double->string ][ 67 ][ 227 ][ 112 ][ !!! *45* !!! ]] + [[ char*->char ][ !!! *<1* !!! ][ 132 ][ 12 ][ 8 ]] + [[ char*->signed char ][ !!! *<1* !!! ][ 98 ][ 11 ][ 9 ]] + [[ char*->unsigned char ][ !!! *<1* !!! ][ 96 ][ 10 ][ 9 ]] + [[ char*->int ][ !!! *6* !!! ][ 109 ][ 22 ][ 14 ]] + [[ char*->short ][ !!! *5* !!! ][ 109 ][ 26 ][ 14 ]] + [[ char*->long int ][ !!! *7* !!! ][ 111 ][ 23 ][ 14 ]] + [[ char*->long long ][ !!! *8* !!! ][ 112 ][ 25 ][ 16 ]] + [[ char*->unsigned int ][ !!! *6* !!! ][ 113 ][ 19 ][ 14 ]] + [[ char*->unsigned short ][ !!! *6* !!! ][ 111 ][ 20 ][ 14 ]] + [[ char*->unsigned long int ][ !!! *7* !!! ][ 109 ][ 21 ][ 14 ]] + [[ char*->unsigned long long ][ !!! *7* !!! ][ 111 ][ 22 ][ 14 ]] + [[ char*->float ][ !!! *12* !!! ][ 156 ][ 62 ][ 32 ]] + [[ char*->double ][ !!! *13* !!! ][ 156 ][ 65 ][ 33 ]] + [[ char*->long double ][ 108 ][ 156 ][ 59 ][ !!! *36* !!! ]] + [[ char*->string ][ !!! *7* !!! ][ 123 ][ 29 ][ --- ]] + [[ char*->container::string ][ !!! *2* !!! ][ 116 ][ 24 ][ --- ]] + [[ unsigned char*->char ][ !!! *<1* !!! ][ 96 ][ 12 ][ 8 ]] + [[ unsigned char*->signed char ][ !!! *<1* !!! ][ 97 ][ 9 ][ 9 ]] + [[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 93 ][ 10 ][ 9 ]] + [[ unsigned char*->int ][ !!! *6* !!! ][ 110 ][ 22 ][ 14 ]] + [[ unsigned char*->short ][ !!! *6* !!! ][ 111 ][ 22 ][ 15 ]] + [[ unsigned char*->long int ][ !!! *8* !!! ][ 110 ][ 23 ][ 14 ]] + [[ unsigned char*->long long ][ !!! *7* !!! ][ 111 ][ 25 ][ 14 ]] + [[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 111 ][ 21 ][ 16 ]] + [[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 110 ][ 21 ][ 15 ]] + [[ unsigned char*->unsigned long int ][ !!! *8* !!! ][ 114 ][ 21 ][ 14 ]] + [[ unsigned char*->unsigned long long ][ !!! *8* !!! ][ 108 ][ 23 ][ 15 ]] + [[ unsigned char*->float ][ !!! *12* !!! ][ 154 ][ 62 ][ 33 ]] + [[ unsigned char*->double ][ !!! *14* !!! ][ 157 ][ 65 ][ 32 ]] + [[ unsigned char*->long double ][ 107 ][ 154 ][ 56 ][ !!! *36* !!! ]] + [[ unsigned char*->string ][ !!! *9* !!! ][ 122 ][ 28 ][ --- ]] + [[ unsigned char*->container::string ][ !!! *4* !!! ][ 118 ][ 26 ][ --- ]] + [[ signed char*->char ][ !!! *<1* !!! ][ 94 ][ 10 ][ 8 ]] + [[ signed char*->signed char ][ !!! *<1* !!! ][ 94 ][ 12 ][ 9 ]] + [[ signed char*->unsigned char ][ !!! *<1* !!! ][ 95 ][ 12 ][ 9 ]] + [[ signed char*->int ][ !!! *7* !!! ][ 109 ][ 22 ][ 14 ]] + [[ signed char*->short ][ !!! *5* !!! ][ 108 ][ 22 ][ 14 ]] + [[ signed char*->long int ][ !!! *7* !!! ][ 110 ][ 23 ][ 14 ]] + [[ signed char*->long long ][ !!! *7* !!! ][ 110 ][ 25 ][ 15 ]] + [[ signed char*->unsigned int ][ !!! *6* !!! ][ 109 ][ 20 ][ 15 ]] + [[ signed char*->unsigned short ][ !!! *6* !!! ][ 107 ][ 21 ][ 14 ]] + [[ signed char*->unsigned long int ][ !!! *8* !!! ][ 111 ][ 21 ][ 14 ]] + [[ signed char*->unsigned long long ][ !!! *7* !!! ][ 109 ][ 23 ][ 14 ]] + [[ signed char*->float ][ !!! *12* !!! ][ 156 ][ 61 ][ 31 ]] + [[ signed char*->double ][ !!! *13* !!! ][ 156 ][ 68 ][ 33 ]] + [[ signed char*->long double ][ 109 ][ 159 ][ 56 ][ !!! *36* !!! ]] + [[ signed char*->string ][ !!! *9* !!! ][ 123 ][ 28 ][ --- ]] + [[ signed char*->container::string ][ !!! *4* !!! ][ 125 ][ 25 ][ --- ]] + [[ iterator_range->char ][ !!! *<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 gcc-4.5][table:id Performance Table (gcc-4.5) + +[section GNU C++ version 4.5.4] +[table:id Performance Table ( GNU C++ version 4.5.4) [[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] -[[ string->char ][ !!! *<1* !!! ][ 91 ][ 8 ][ 7 ]] -[[ string->signed char ][ !!! *<1* !!! ][ 91 ][ 8 ][ 7 ]] -[[ string->unsigned char ][ !!! *<1* !!! ][ 90 ][ 8 ][ 13 ]] -[[ string->int ][ !!! *3* !!! ][ 100 ][ 20 ][ 14 ]] -[[ string->short ][ !!! *3* !!! ][ 106 ][ 20 ][ 14 ]] -[[ string->long int ][ !!! *3* !!! ][ 100 ][ 18 ][ 14 ]] -[[ string->long long ][ !!! *9* !!! ][ 100 ][ 18 ][ 15 ]] -[[ string->unsigned int ][ !!! *3* !!! ][ 97 ][ 20 ][ 14 ]] -[[ string->unsigned short ][ !!! *3* !!! ][ 102 ][ 17 ][ 14 ]] -[[ string->unsigned long int ][ !!! *3* !!! ][ 97 ][ 21 ][ 14 ]] -[[ string->unsigned long long ][ !!! *3* !!! ][ 97 ][ 19 ][ 14 ]] -[[ string->bool ][ !!! *<1* !!! ][ 95 ][ 16 ][ 7 ]] -[[ string->float ][ !!! *15* !!! ][ 157 ][ 63 ][ 32 ]] -[[ string->double ][ !!! *17* !!! ][ 203 ][ 95 ][ 59 ]] -[[ string->long double ][ 129 ][ 216 ][ 93 ][ !!! *58* !!! ]] -[[ char->string ][ !!! *8* !!! ][ 100 ][ 17 ][ 10 ]] -[[ unsigned char->string ][ !!! *8* !!! ][ 96 ][ 18 ][ 16 ]] -[[ signed char->string ][ !!! *8* !!! ][ 96 ][ 18 ][ 10 ]] -[[ int->string ][ !!! *14* !!! ][ 105 ][ 22 ][ 15 ]] -[[ short->string ][ !!! *14* !!! ][ 107 ][ 23 ][ 17 ]] -[[ long int->string ][ !!! *14* !!! ][ 109 ][ 22 ][ 17 ]] -[[ long long->string ][ !!! *14* !!! ][ 105 ][ 22 ][ 18 ]] -[[ unsigned int->string ][ !!! *14* !!! ][ 105 ][ 25 ][ 15 ]] -[[ unsigned short->string ][ !!! *15* !!! ][ 105 ][ 23 ][ 17 ]] -[[ unsigned long int->string ][ !!! *14* !!! ][ 109 ][ 24 ][ 17 ]] -[[ unsigned long long->string ][ !!! *14* !!! ][ 102 ][ 23 ][ 17 ]] -[[ bool->string ][ !!! *8* !!! ][ 104 ][ 23 ][ 12 ]] -[[ float->string ][ 66 ][ 181 ][ 92 ][ !!! *49* !!! ]] -[[ double->string ][ 107 ][ 215 ][ 120 ][ !!! *75* !!! ]] -[[ long double->string ][ 117 ][ 221 ][ 125 ][ !!! *79* !!! ]] -[[ char*->char ][ !!! *1* !!! ][ 89 ][ 9 ][ 7 ]] -[[ char*->signed char ][ !!! *1* !!! ][ 90 ][ 9 ][ 7 ]] -[[ char*->unsigned char ][ !!! *2* !!! ][ 90 ][ 9 ][ 13 ]] -[[ char*->int ][ !!! *7* !!! ][ 103 ][ 20 ][ 15 ]] -[[ char*->short ][ !!! *6* !!! ][ 102 ][ 29 ][ 14 ]] -[[ char*->long int ][ !!! *7* !!! ][ 101 ][ 20 ][ 15 ]] -[[ char*->long long ][ !!! *6* !!! ][ 102 ][ 20 ][ 14 ]] -[[ char*->unsigned int ][ !!! *6* !!! ][ 99 ][ 19 ][ 14 ]] -[[ char*->unsigned short ][ !!! *6* !!! ][ 101 ][ 18 ][ 14 ]] -[[ char*->unsigned long int ][ !!! *6* !!! ][ 102 ][ 22 ][ 14 ]] -[[ char*->unsigned long long ][ !!! *6* !!! ][ 101 ][ 21 ][ 14 ]] -[[ char*->bool ][ !!! *3* !!! ][ 98 ][ 18 ][ 7 ]] -[[ char*->float ][ !!! *18* !!! ][ 162 ][ 63 ][ 31 ]] -[[ char*->double ][ !!! *17* !!! ][ 203 ][ 96 ][ 58 ]] -[[ char*->long double ][ 135 ][ 214 ][ 98 ][ !!! *58* !!! ]] -[[ unsigned char*->char ][ !!! *2* !!! ][ 87 ][ 9 ][ 7 ]] -[[ unsigned char*->signed char ][ !!! *2* !!! ][ 87 ][ 9 ][ 7 ]] -[[ unsigned char*->unsigned char ][ !!! *3* !!! ][ 87 ][ 9 ][ 13 ]] -[[ unsigned char*->int ][ !!! *6* !!! ][ 105 ][ 20 ][ 14 ]] -[[ unsigned char*->short ][ !!! *6* !!! ][ 102 ][ 21 ][ 14 ]] -[[ unsigned char*->long int ][ !!! *6* !!! ][ 101 ][ 20 ][ 14 ]] -[[ unsigned char*->long long ][ !!! *6* !!! ][ 102 ][ 20 ][ 14 ]] -[[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 99 ][ 19 ][ 14 ]] -[[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 100 ][ 18 ][ 14 ]] -[[ unsigned char*->unsigned long int ][ !!! *6* !!! ][ 101 ][ 24 ][ 14 ]] -[[ unsigned char*->unsigned long long ][ !!! *6* !!! ][ 100 ][ 20 ][ 14 ]] -[[ unsigned char*->bool ][ !!! *3* !!! ][ 99 ][ 18 ][ 8 ]] -[[ unsigned char*->float ][ !!! *17* !!! ][ 164 ][ 64 ][ 32 ]] -[[ unsigned char*->double ][ !!! *18* !!! ][ 201 ][ 94 ][ 58 ]] -[[ unsigned char*->long double ][ 133 ][ 217 ][ 95 ][ !!! *60* !!! ]] -[[ unsigned char*->string ][ !!! *14* !!! ][ 103 ][ 23 ][ --- ]] -[[ signed char*->char ][ !!! *3* !!! ][ 88 ][ 10 ][ 8 ]] -[[ signed char*->signed char ][ !!! *2* !!! ][ 87 ][ 10 ][ 7 ]] -[[ signed char*->unsigned char ][ !!! *3* !!! ][ 87 ][ 9 ][ 13 ]] -[[ signed char*->int ][ !!! *6* !!! ][ 104 ][ 20 ][ 14 ]] -[[ signed char*->short ][ !!! *6* !!! ][ 105 ][ 21 ][ 14 ]] -[[ signed char*->long int ][ !!! *6* !!! ][ 104 ][ 20 ][ 15 ]] -[[ signed char*->long long ][ !!! *6* !!! ][ 106 ][ 20 ][ 14 ]] -[[ signed char*->unsigned int ][ !!! *6* !!! ][ 99 ][ 20 ][ 14 ]] -[[ signed char*->unsigned short ][ !!! *6* !!! ][ 100 ][ 18 ][ 14 ]] -[[ signed char*->unsigned long int ][ !!! *6* !!! ][ 102 ][ 23 ][ 14 ]] -[[ signed char*->unsigned long long ][ !!! *6* !!! ][ 103 ][ 20 ][ 14 ]] -[[ signed char*->bool ][ !!! *3* !!! ][ 99 ][ 18 ][ 7 ]] -[[ signed char*->float ][ !!! *18* !!! ][ 159 ][ 60 ][ 32 ]] -[[ signed char*->double ][ !!! *18* !!! ][ 203 ][ 95 ][ 57 ]] -[[ signed char*->long double ][ 129 ][ 213 ][ 97 ][ !!! *56* !!! ]] -[[ signed char*->string ][ !!! *14* !!! ][ 105 ][ 22 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 109 ][ 22 ][ --- ]] -[[ float->double ][ !!! *<1* !!! ][ 226 ][ 104 ][ --- ]] -[[ double->double ][ !!! *<1* !!! ][ 229 ][ 103 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 225 ][ 115 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 227 ][ 115 ][ --- ]] -[[ char->unsigned char ][ !!! *<1* !!! ][ 90 ][ 8 ][ --- ]] -[[ char->signed char ][ !!! *<1* !!! ][ 84 ][ 8 ][ --- ]] -[[ unsigned char->char ][ !!! *<1* !!! ][ 88 ][ 8 ][ --- ]] -[[ signed char->char ][ !!! *<1* !!! ][ 89 ][ 8 ][ --- ]] + [[ string->char ][ !!! *<1* !!! ][ 147 ][ 12 ][ 8 ]] + [[ string->signed char ][ !!! *<1* !!! ][ 138 ][ 13 ][ 10 ]] + [[ string->unsigned char ][ !!! *<1* !!! ][ 86 ][ 12 ][ 9 ]] + [[ string->int ][ !!! *7* !!! ][ 103 ][ 20 ][ 15 ]] + [[ string->short ][ !!! *5* !!! ][ 103 ][ 20 ][ 15 ]] + [[ string->long int ][ !!! *7* !!! ][ 103 ][ 22 ][ 15 ]] + [[ string->long long ][ !!! *7* !!! ][ 104 ][ 22 ][ 16 ]] + [[ string->unsigned int ][ !!! *6* !!! ][ 108 ][ 19 ][ 15 ]] + [[ string->unsigned short ][ !!! *5* !!! ][ 104 ][ 19 ][ 15 ]] + [[ string->unsigned long int ][ !!! *7* !!! ][ 103 ][ 20 ][ 16 ]] + [[ string->unsigned long long ][ !!! *7* !!! ][ 101 ][ 22 ][ 14 ]] + [[ string->float ][ !!! *13* !!! ][ 148 ][ 58 ][ 35 ]] + [[ string->double ][ !!! *13* !!! ][ 147 ][ 60 ][ 34 ]] + [[ string->long double ][ 103 ][ 149 ][ 56 ][ !!! *38* !!! ]] + [[ string->string ][ !!! *2* !!! ][ 127 ][ 27 ][ --- ]] + [[ string->container::string ][ !!! *3* !!! ][ 101 ][ 24 ][ --- ]] + [[ string->char ][ !!! *7* !!! ][ 108 ][ 35 ][ 17 ]] + [[ string->signed char ][ !!! *7* !!! ][ 112 ][ 26 ][ 23 ]] + [[ string->unsigned char ][ !!! *7* !!! ][ 113 ][ 25 ][ 25 ]] + [[ int->string ][ !!! *11* !!! ][ 183 ][ 47 ][ 40 ]] + [[ short->string ][ !!! *14* !!! ][ 153 ][ 35 ][ 23 ]] + [[ long int->string ][ !!! *12* !!! ][ 135 ][ 32 ][ 22 ]] + [[ long long->string ][ !!! *11* !!! ][ 131 ][ 30 ][ 24 ]] + [[ unsigned int->string ][ !!! *12* !!! ][ 137 ][ 31 ][ 22 ]] + [[ unsigned short->string ][ !!! *11* !!! ][ 137 ][ 33 ][ 22 ]] + [[ unsigned long int->string ][ !!! *11* !!! ][ 136 ][ 36 ][ 23 ]] + [[ unsigned long long->string ][ !!! *11* !!! ][ 127 ][ 29 ][ 23 ]] + [[ float->string ][ 56 ][ 218 ][ 107 ][ !!! *44* !!! ]] + [[ double->string ][ 63 ][ 223 ][ 106 ][ !!! *44* !!! ]] + [[ long double->string ][ 69 ][ 229 ][ 118 ][ !!! *49* !!! ]] + [[ char*->char ][ !!! *<1* !!! ][ 91 ][ 12 ][ 9 ]] + [[ char*->signed char ][ !!! *<1* !!! ][ 100 ][ 11 ][ 11 ]] + [[ char*->unsigned char ][ !!! *<1* !!! ][ 97 ][ 12 ][ 10 ]] + [[ char*->int ][ !!! *7* !!! ][ 112 ][ 23 ][ 16 ]] + [[ char*->short ][ !!! *6* !!! ][ 116 ][ 23 ][ 16 ]] + [[ char*->long int ][ !!! *8* !!! ][ 113 ][ 23 ][ 16 ]] + [[ char*->long long ][ !!! *8* !!! ][ 122 ][ 28 ][ 16 ]] + [[ char*->unsigned int ][ !!! *6* !!! ][ 117 ][ 21 ][ 15 ]] + [[ char*->unsigned short ][ !!! *6* !!! ][ 113 ][ 21 ][ 16 ]] + [[ char*->unsigned long int ][ !!! *7* !!! ][ 118 ][ 22 ][ 16 ]] + [[ char*->unsigned long long ][ !!! *8* !!! ][ 113 ][ 22 ][ 17 ]] + [[ char*->float ][ !!! *11* !!! ][ 164 ][ 67 ][ 34 ]] + [[ char*->double ][ !!! *13* !!! ][ 163 ][ 66 ][ 35 ]] + [[ char*->long double ][ 110 ][ 164 ][ 63 ][ !!! *39* !!! ]] + [[ char*->string ][ !!! *8* !!! ][ 130 ][ 30 ][ --- ]] + [[ char*->container::string ][ !!! *2* !!! ][ 113 ][ 24 ][ --- ]] + [[ unsigned char*->char ][ !!! *<1* !!! ][ 98 ][ 11 ][ 10 ]] + [[ unsigned char*->signed char ][ !!! *<1* !!! ][ 97 ][ 12 ][ 10 ]] + [[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 97 ][ 11 ][ 10 ]] + [[ unsigned char*->int ][ !!! *7* !!! ][ 112 ][ 23 ][ 16 ]] + [[ unsigned char*->short ][ !!! *6* !!! ][ 115 ][ 22 ][ 20 ]] + [[ unsigned char*->long int ][ !!! *8* !!! ][ 112 ][ 23 ][ 15 ]] + [[ unsigned char*->long long ][ !!! *8* !!! ][ 115 ][ 29 ][ 17 ]] + [[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 114 ][ 21 ][ 14 ]] + [[ unsigned char*->unsigned short ][ !!! *7* !!! ][ 112 ][ 22 ][ 15 ]] + [[ unsigned char*->unsigned long int ][ !!! *7* !!! ][ 115 ][ 23 ][ 14 ]] + [[ unsigned char*->unsigned long long ][ !!! *8* !!! ][ 112 ][ 24 ][ 15 ]] + [[ unsigned char*->float ][ !!! *12* !!! ][ 161 ][ 66 ][ 34 ]] + [[ unsigned char*->double ][ !!! *13* !!! ][ 162 ][ 66 ][ 36 ]] + [[ unsigned char*->long double ][ 112 ][ 161 ][ 63 ][ !!! *39* !!! ]] + [[ unsigned char*->string ][ !!! *9* !!! ][ 127 ][ 29 ][ --- ]] + [[ unsigned char*->container::string ][ !!! *4* !!! ][ 111 ][ 25 ][ --- ]] + [[ signed char*->char ][ !!! *<1* !!! ][ 104 ][ 11 ][ 8 ]] + [[ signed char*->signed char ][ !!! *<1* !!! ][ 98 ][ 11 ][ 11 ]] + [[ signed char*->unsigned char ][ !!! *<1* !!! ][ 98 ][ 11 ][ 11 ]] + [[ signed char*->int ][ !!! *7* !!! ][ 112 ][ 23 ][ 16 ]] + [[ signed char*->short ][ !!! *7* !!! ][ 113 ][ 23 ][ 15 ]] + [[ signed char*->long int ][ !!! *8* !!! ][ 112 ][ 22 ][ 14 ]] + [[ signed char*->long long ][ !!! *8* !!! ][ 115 ][ 25 ][ 16 ]] + [[ signed char*->unsigned int ][ !!! *8* !!! ][ 114 ][ 21 ][ 18 ]] + [[ signed char*->unsigned short ][ !!! *6* !!! ][ 112 ][ 22 ][ 15 ]] + [[ signed char*->unsigned long int ][ !!! *8* !!! ][ 116 ][ 22 ][ 15 ]] + [[ signed char*->unsigned long long ][ !!! *8* !!! ][ 113 ][ 23 ][ 16 ]] + [[ signed char*->float ][ !!! *13* !!! ][ 161 ][ 65 ][ 34 ]] + [[ signed char*->double ][ !!! *12* !!! ][ 172 ][ 67 ][ 34 ]] + [[ signed char*->long double ][ 110 ][ 164 ][ 63 ][ !!! *38* !!! ]] + [[ signed char*->string ][ !!! *9* !!! ][ 131 ][ 30 ][ --- ]] + [[ signed char*->container::string ][ !!! *4* !!! ][ 112 ][ 24 ][ --- ]] + [[ iterator_range->char ][ !!! *<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 gcc-4.6][table:id Performance Table (gcc-4.6) + +[section GNU C++ version 4.4.6] +[table:id Performance Table ( GNU C++ version 4.4.6) [[From->To] [lexical_cast] [std::stringstream with construction] [std::stringstream without construction][scanf/printf]] -[[ string->char ][ !!! *<1* !!! ][ 94 ][ 8 ][ 7 ]] -[[ string->signed char ][ !!! *<1* !!! ][ 96 ][ 9 ][ 7 ]] -[[ string->unsigned char ][ !!! *<1* !!! ][ 96 ][ 8 ][ 13 ]] -[[ string->int ][ !!! *3* !!! ][ 110 ][ 18 ][ 16 ]] -[[ string->short ][ !!! *3* !!! ][ 111 ][ 18 ][ 16 ]] -[[ string->long int ][ !!! *3* !!! ][ 109 ][ 18 ][ 15 ]] -[[ string->long long ][ !!! *3* !!! ][ 111 ][ 18 ][ 15 ]] -[[ string->unsigned int ][ !!! *3* !!! ][ 110 ][ 20 ][ 15 ]] -[[ string->unsigned short ][ !!! *3* !!! ][ 111 ][ 18 ][ 15 ]] -[[ string->unsigned long int ][ !!! *3* !!! ][ 109 ][ 18 ][ 15 ]] -[[ string->unsigned long long ][ !!! *3* !!! ][ 114 ][ 19 ][ 15 ]] -[[ string->bool ][ !!! *<1* !!! ][ 106 ][ 17 ][ 8 ]] -[[ string->float ][ !!! *13* !!! ][ 175 ][ 70 ][ 33 ]] -[[ string->double ][ !!! *14* !!! ][ 182 ][ 81 ][ 58 ]] -[[ string->long double ][ 118 ][ 190 ][ 87 ][ !!! *58* !!! ]] -[[ char->string ][ !!! *8* !!! ][ 118 ][ 21 ][ 12 ]] -[[ unsigned char->string ][ !!! *8* !!! ][ 109 ][ 18 ][ 16 ]] -[[ signed char->string ][ !!! *8* !!! ][ 108 ][ 18 ][ 12 ]] -[[ int->string ][ 20 ][ 121 ][ 21 ][ !!! *16* !!! ]] -[[ short->string ][ !!! *15* !!! ][ 120 ][ 22 ][ 17 ]] -[[ long int->string ][ !!! *15* !!! ][ 120 ][ 22 ][ 16 ]] -[[ long long->string ][ !!! *15* !!! ][ 120 ][ 22 ][ 17 ]] -[[ unsigned int->string ][ !!! *15* !!! ][ 120 ][ 22 ][ 16 ]] -[[ unsigned short->string ][ !!! *15* !!! ][ 120 ][ 22 ][ 18 ]] -[[ unsigned long int->string ][ 16 ][ 118 ][ 22 ][ !!! *15* !!! ]] -[[ unsigned long long->string ][ !!! *15* !!! ][ 117 ][ 21 ][ 17 ]] -[[ bool->string ][ !!! *8* !!! ][ 117 ][ 23 ][ 10 ]] -[[ float->string ][ 77 ][ 218 ][ 105 ][ !!! *50* !!! ]] -[[ double->string ][ 108 ][ 247 ][ 129 ][ !!! *73* !!! ]] -[[ long double->string ][ 120 ][ 250 ][ 131 ][ !!! *79* !!! ]] -[[ char*->char ][ !!! *2* !!! ][ 99 ][ 9 ][ 7 ]] -[[ char*->signed char ][ !!! *2* !!! ][ 98 ][ 9 ][ 8 ]] -[[ char*->unsigned char ][ !!! *2* !!! ][ 98 ][ 9 ][ 13 ]] -[[ char*->int ][ !!! *6* !!! ][ 115 ][ 22 ][ 15 ]] -[[ char*->short ][ !!! *6* !!! ][ 114 ][ 22 ][ 15 ]] -[[ char*->long int ][ !!! *6* !!! ][ 114 ][ 22 ][ 16 ]] -[[ char*->long long ][ !!! *6* !!! ][ 119 ][ 22 ][ 15 ]] -[[ char*->unsigned int ][ !!! *6* !!! ][ 114 ][ 20 ][ 15 ]] -[[ char*->unsigned short ][ !!! *6* !!! ][ 116 ][ 20 ][ 15 ]] -[[ char*->unsigned long int ][ !!! *6* !!! ][ 117 ][ 22 ][ 15 ]] -[[ char*->unsigned long long ][ !!! *6* !!! ][ 118 ][ 22 ][ 15 ]] -[[ char*->bool ][ !!! *3* !!! ][ 113 ][ 18 ][ 8 ]] -[[ char*->float ][ !!! *15* !!! ][ 180 ][ 78 ][ 32 ]] -[[ char*->double ][ !!! *16* !!! ][ 185 ][ 89 ][ 58 ]] -[[ char*->long double ][ 119 ][ 193 ][ 91 ][ !!! *60* !!! ]] -[[ unsigned char*->char ][ !!! *2* !!! ][ 99 ][ 9 ][ 8 ]] -[[ unsigned char*->signed char ][ !!! *2* !!! ][ 99 ][ 10 ][ 8 ]] -[[ unsigned char*->unsigned char ][ !!! *2* !!! ][ 100 ][ 9 ][ 15 ]] -[[ unsigned char*->int ][ !!! *6* !!! ][ 118 ][ 22 ][ 15 ]] -[[ unsigned char*->short ][ !!! *6* !!! ][ 117 ][ 26 ][ 15 ]] -[[ unsigned char*->long int ][ !!! *6* !!! ][ 119 ][ 21 ][ 15 ]] -[[ unsigned char*->long long ][ !!! *6* !!! ][ 118 ][ 21 ][ 14 ]] -[[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 115 ][ 22 ][ 14 ]] -[[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 117 ][ 20 ][ 15 ]] -[[ unsigned char*->unsigned long int ][ !!! *6* !!! ][ 115 ][ 21 ][ 15 ]] -[[ unsigned char*->unsigned long long ][ !!! *6* !!! ][ 117 ][ 22 ][ 15 ]] -[[ unsigned char*->bool ][ !!! *3* !!! ][ 112 ][ 18 ][ 8 ]] -[[ unsigned char*->float ][ !!! *15* !!! ][ 181 ][ 78 ][ 33 ]] -[[ unsigned char*->double ][ !!! *16* !!! ][ 185 ][ 92 ][ 59 ]] -[[ unsigned char*->long double ][ 120 ][ 190 ][ 89 ][ !!! *58* !!! ]] -[[ unsigned char*->string ][ !!! *14* !!! ][ 121 ][ 22 ][ --- ]] -[[ signed char*->char ][ !!! *2* !!! ][ 99 ][ 9 ][ 9 ]] -[[ signed char*->signed char ][ !!! *2* !!! ][ 98 ][ 9 ][ 8 ]] -[[ signed char*->unsigned char ][ !!! *2* !!! ][ 98 ][ 9 ][ 14 ]] -[[ signed char*->int ][ !!! *6* !!! ][ 119 ][ 22 ][ 16 ]] -[[ signed char*->short ][ !!! *6* !!! ][ 115 ][ 22 ][ 15 ]] -[[ signed char*->long int ][ !!! *6* !!! ][ 119 ][ 22 ][ 15 ]] -[[ signed char*->long long ][ !!! *6* !!! ][ 117 ][ 22 ][ 15 ]] -[[ signed char*->unsigned int ][ !!! *6* !!! ][ 117 ][ 23 ][ 15 ]] -[[ signed char*->unsigned short ][ !!! *6* !!! ][ 117 ][ 21 ][ 14 ]] -[[ signed char*->unsigned long int ][ !!! *7* !!! ][ 119 ][ 24 ][ 15 ]] -[[ signed char*->unsigned long long ][ !!! *6* !!! ][ 116 ][ 22 ][ 15 ]] -[[ signed char*->bool ][ !!! *3* !!! ][ 111 ][ 18 ][ 8 ]] -[[ signed char*->float ][ !!! *16* !!! ][ 180 ][ 78 ][ 33 ]] -[[ signed char*->double ][ !!! *16* !!! ][ 185 ][ 89 ][ 59 ]] -[[ signed char*->long double ][ 120 ][ 191 ][ 91 ][ !!! *59* !!! ]] -[[ signed char*->string ][ !!! *14* !!! ][ 122 ][ 23 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 120 ][ 22 ][ --- ]] -[[ float->double ][ !!! *<1* !!! ][ 242 ][ 115 ][ --- ]] -[[ double->double ][ !!! *<1* !!! ][ 243 ][ 115 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 265 ][ 141 ][ --- ]] -[[ int->int ][ !!! *<1* !!! ][ 266 ][ 140 ][ --- ]] -[[ char->unsigned char ][ !!! *<1* !!! ][ 95 ][ 8 ][ --- ]] -[[ char->signed char ][ !!! *<1* !!! ][ 95 ][ 8 ][ --- ]] -[[ unsigned char->char ][ !!! *<1* !!! ][ 94 ][ 8 ][ --- ]] -[[ signed char->char ][ !!! *<1* !!! ][ 94 ][ 8 ][ --- ]] + [[ string->char ][ !!! *<1* !!! ][ 162 ][ 17 ][ 8 ]] + [[ string->signed char ][ !!! *<1* !!! ][ 103 ][ 9 ][ 9 ]] + [[ string->unsigned char ][ !!! *<1* !!! ][ 91 ][ 9 ][ 9 ]] + [[ string->int ][ !!! *6* !!! ][ 104 ][ 21 ][ 14 ]] + [[ string->short ][ !!! *5* !!! ][ 107 ][ 22 ][ 14 ]] + [[ string->long int ][ !!! *7* !!! ][ 106 ][ 23 ][ 15 ]] + [[ string->long long ][ !!! *7* !!! ][ 104 ][ 21 ][ 16 ]] + [[ string->unsigned int ][ !!! *6* !!! ][ 100 ][ 20 ][ 16 ]] + [[ string->unsigned short ][ !!! *5* !!! ][ 102 ][ 20 ][ 16 ]] + [[ string->unsigned long int ][ !!! *7* !!! ][ 106 ][ 25 ][ 16 ]] + [[ string->unsigned long long ][ !!! *7* !!! ][ 109 ][ 25 ][ 14 ]] + [[ string->float ][ !!! *13* !!! ][ 142 ][ 48 ][ 32 ]] + [[ string->double ][ !!! *13* !!! ][ 162 ][ 62 ][ 33 ]] + [[ string->long double ][ 119 ][ 164 ][ 62 ][ !!! *37* !!! ]] + [[ string->string ][ !!! *2* !!! ][ 122 ][ 27 ][ --- ]] + [[ string->container::string ][ !!! *2* !!! ][ 107 ][ 23 ][ --- ]] + [[ string->char ][ !!! *6* !!! ][ 110 ][ 24 ][ 15 ]] + [[ string->signed char ][ !!! *6* !!! ][ 107 ][ 24 ][ 21 ]] + [[ string->unsigned char ][ !!! *6* !!! ][ 106 ][ 27 ][ 21 ]] + [[ int->string ][ !!! *12* !!! ][ 122 ][ 31 ][ 21 ]] + [[ short->string ][ !!! *12* !!! ][ 136 ][ 29 ][ 20 ]] + [[ long int->string ][ !!! *12* !!! ][ 127 ][ 32 ][ 19 ]] + [[ long long->string ][ !!! *12* !!! ][ 121 ][ 32 ][ 21 ]] + [[ unsigned int->string ][ !!! *12* !!! ][ 133 ][ 32 ][ 19 ]] + [[ unsigned short->string ][ !!! *12* !!! ][ 126 ][ 33 ][ 20 ]] + [[ unsigned long int->string ][ !!! *11* !!! ][ 126 ][ 34 ][ 19 ]] + [[ unsigned long long->string ][ !!! *12* !!! ][ 125 ][ 28 ][ 21 ]] + [[ float->string ][ 47 ][ 183 ][ 86 ][ !!! *43* !!! ]] + [[ double->string ][ 57 ][ 184 ][ 90 ][ !!! *42* !!! ]] + [[ long double->string ][ 64 ][ 199 ][ 87 ][ !!! *46* !!! ]] + [[ char*->char ][ !!! *<1* !!! ][ 95 ][ 10 ][ 8 ]] + [[ char*->signed char ][ !!! *<1* !!! ][ 90 ][ 12 ][ 9 ]] + [[ char*->unsigned char ][ !!! *<1* !!! ][ 93 ][ 12 ][ 9 ]] + [[ char*->int ][ !!! *6* !!! ][ 108 ][ 24 ][ 14 ]] + [[ char*->short ][ !!! *6* !!! ][ 106 ][ 23 ][ 14 ]] + [[ char*->long int ][ !!! *7* !!! ][ 107 ][ 24 ][ 17 ]] + [[ char*->long long ][ !!! *7* !!! ][ 109 ][ 25 ][ 17 ]] + [[ char*->unsigned int ][ !!! *6* !!! ][ 104 ][ 23 ][ 17 ]] + [[ char*->unsigned short ][ !!! *6* !!! ][ 102 ][ 22 ][ 17 ]] + [[ char*->unsigned long int ][ !!! *7* !!! ][ 107 ][ 23 ][ 17 ]] + [[ char*->unsigned long long ][ !!! *7* !!! ][ 115 ][ 26 ][ 14 ]] + [[ char*->float ][ !!! *12* !!! ][ 150 ][ 56 ][ 30 ]] + [[ char*->double ][ !!! *12* !!! ][ 165 ][ 66 ][ 32 ]] + [[ char*->long double ][ 116 ][ 173 ][ 66 ][ !!! *37* !!! ]] + [[ char*->string ][ !!! *7* !!! ][ 120 ][ 28 ][ --- ]] + [[ char*->container::string ][ !!! *2* !!! ][ 108 ][ 26 ][ --- ]] + [[ unsigned char*->char ][ !!! *<1* !!! ][ 90 ][ 12 ][ 8 ]] + [[ unsigned char*->signed char ][ !!! *<1* !!! ][ 91 ][ 11 ][ 9 ]] + [[ unsigned char*->unsigned char ][ !!! *<1* !!! ][ 91 ][ 12 ][ 9 ]] + [[ unsigned char*->int ][ !!! *6* !!! ][ 106 ][ 24 ][ 14 ]] + [[ unsigned char*->short ][ !!! *6* !!! ][ 108 ][ 24 ][ 14 ]] + [[ unsigned char*->long int ][ !!! *7* !!! ][ 116 ][ 23 ][ 14 ]] + [[ unsigned char*->long long ][ !!! *7* !!! ][ 108 ][ 28 ][ 14 ]] + [[ unsigned char*->unsigned int ][ !!! *6* !!! ][ 107 ][ 22 ][ 14 ]] + [[ unsigned char*->unsigned short ][ !!! *6* !!! ][ 105 ][ 21 ][ 16 ]] + [[ unsigned char*->unsigned long int ][ !!! *7* !!! ][ 106 ][ 25 ][ 16 ]] + [[ unsigned char*->unsigned long long ][ !!! *7* !!! ][ 105 ][ 24 ][ 17 ]] + [[ unsigned char*->float ][ !!! *14* !!! ][ 150 ][ 57 ][ 33 ]] + [[ unsigned char*->double ][ !!! *14* !!! ][ 171 ][ 72 ][ 34 ]] + [[ unsigned char*->long double ][ 118 ][ 171 ][ 73 ][ !!! *38* !!! ]] + [[ unsigned char*->string ][ !!! *8* !!! ][ 120 ][ 29 ][ --- ]] + [[ unsigned char*->container::string ][ !!! *3* !!! ][ 114 ][ 26 ][ --- ]] + [[ signed char*->char ][ !!! *<1* !!! ][ 92 ][ 12 ][ 8 ]] + [[ signed char*->signed char ][ !!! *<1* !!! ][ 92 ][ 12 ][ 9 ]] + [[ signed char*->unsigned char ][ !!! *<1* !!! ][ 91 ][ 14 ][ 9 ]] + [[ signed char*->int ][ !!! *6* !!! ][ 109 ][ 22 ][ 15 ]] + [[ signed char*->short ][ !!! *6* !!! ][ 106 ][ 24 ][ 17 ]] + [[ signed char*->long int ][ !!! *7* !!! ][ 107 ][ 24 ][ 16 ]] + [[ signed char*->long long ][ !!! *7* !!! ][ 106 ][ 24 ][ 14 ]] + [[ signed char*->unsigned int ][ !!! *6* !!! ][ 106 ][ 22 ][ 14 ]] + [[ signed char*->unsigned short ][ !!! *6* !!! ][ 104 ][ 20 ][ 14 ]] + [[ signed char*->unsigned long int ][ !!! *7* !!! ][ 105 ][ 22 ][ 16 ]] + [[ signed char*->unsigned long long ][ !!! *7* !!! ][ 108 ][ 24 ][ 15 ]] + [[ signed char*->float ][ !!! *14* !!! ][ 147 ][ 54 ][ 32 ]] + [[ signed char*->double ][ !!! *14* !!! ][ 170 ][ 68 ][ 37 ]] + [[ signed char*->long double ][ 133 ][ 167 ][ 66 ][ !!! *37* !!! ]] + [[ signed char*->string ][ !!! *8* !!! ][ 119 ][ 30 ][ --- ]] + [[ signed char*->container::string ][ !!! *3* !!! ][ 108 ][ 24 ][ --- ]] + [[ iterator_range->char ][ !!! *<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] diff --git a/include/boost/lexical_cast.hpp b/include/boost/lexical_cast.hpp index b73c741..fb1808f 100644 --- a/include/boost/lexical_cast.hpp +++ b/include/boost/lexical_cast.hpp @@ -72,6 +72,7 @@ _CRTIMP int __cdecl vswprintf(wchar_t * __restrict__ , const wchar_t * __restric #include #include #include +#include #if !defined(__SUNPRO_CC) #include #endif // !defined(__SUNPRO_CC) @@ -166,6 +167,18 @@ namespace boost }; #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + template + struct stream_char > + { + typedef BOOST_DEDUCED_TYPENAME stream_char::type type; + }; + + template + struct stream_char > + { + typedef BOOST_DEDUCED_TYPENAME stream_char::type type; + }; + template struct stream_char< std::basic_string > { @@ -1225,7 +1238,7 @@ namespace boost bool shl_char(T ch) { BOOST_STATIC_ASSERT_MSG(( sizeof(T) <= sizeof(CharT)) , - "boost::lexical_cast does not support conversions from whar_t to char types." + "boost::lexical_cast does not support conversions from wchar_t to char types." "Use boost::locale instead" ); #ifndef BOOST_LEXICAL_CAST_ASSUME_C_LOCALE std::locale loc; @@ -1397,6 +1410,52 @@ namespace boost return true; } + bool operator<<(const iterator_range& rng) + { + start = rng.begin(); + finish = rng.end(); + return true; + } + + bool operator<<(const iterator_range& rng) + { + start = const_cast(rng.begin()); + finish = const_cast(rng.end()); + return true; + } + + bool operator<<(const iterator_range& rng) + { + return (*this) << iterator_range( + const_cast(reinterpret_cast(rng.begin())), + const_cast(reinterpret_cast(rng.end())) + ); + } + + bool operator<<(const iterator_range& rng) + { + return (*this) << iterator_range( + const_cast(reinterpret_cast(rng.begin())), + const_cast(reinterpret_cast(rng.end())) + ); + } + + bool operator<<(const iterator_range& rng) + { + return (*this) << iterator_range( + reinterpret_cast(rng.begin()), + reinterpret_cast(rng.end()) + ); + } + + bool operator<<(const iterator_range& rng) + { + return (*this) << iterator_range( + reinterpret_cast(rng.begin()), + reinterpret_cast(rng.end()) + ); + } + bool operator<<(char ch) { return shl_char(ch); } bool operator<<(unsigned char ch) { return ((*this) << static_cast(ch)); } bool operator<<(signed char ch) { return ((*this) << static_cast(ch)); } @@ -1572,7 +1631,7 @@ namespace boost inline bool shr_xchar(T& output) { BOOST_STATIC_ASSERT_MSG(( sizeof(CharT) == sizeof(T) ), - "boost::lexical_cast does not support conversions from whar_t to char types." + "boost::lexical_cast does not support conversions from wchar_t to char types." "Use boost::locale instead" ); bool const ok = (finish - start == 1); if(ok) { @@ -1801,6 +1860,24 @@ namespace boost ); }; + template + struct is_char_iterator_range + { + BOOST_STATIC_CONSTANT(bool, value = false ); + }; + + template + struct is_char_iterator_range > + { + BOOST_STATIC_CONSTANT(bool, value = (is_char_or_wchar::value) ); + }; + + template + struct is_char_iterator_range > + { + BOOST_STATIC_CONSTANT(bool, value = (is_char_or_wchar::value) ); + }; + template struct is_arithmetic_and_not_xchars { @@ -1889,10 +1966,10 @@ namespace boost static inline Target lexical_cast_impl(const Source& arg) { typedef BOOST_DEDUCED_TYPENAME detail::array_to_pointer_decay::type src; - + typedef BOOST_DEDUCED_TYPENAME detail::stream_char::type target_char_t; + typedef BOOST_DEDUCED_TYPENAME detail::stream_char::type src_char_type; typedef BOOST_DEDUCED_TYPENAME detail::widest_char< - BOOST_DEDUCED_TYPENAME detail::stream_char::type - , BOOST_DEDUCED_TYPENAME detail::stream_char::type + target_char_t, src_char_type >::type char_type; typedef detail::lcast_src_length lcast_src_length; @@ -1903,7 +1980,8 @@ namespace boost typedef BOOST_DEDUCED_TYPENAME deduce_char_traits::type traits; - typedef BOOST_DEDUCED_TYPENAME remove_pointer::type removed_ptr_t; + typedef BOOST_DEDUCED_TYPENAME remove_pointer::type removed_ptr_t_1; + typedef BOOST_DEDUCED_TYPENAME remove_cv::type removed_ptr_t; // is_char_types_match variable value can be computed via // sizeof(char_type) == sizeof(removed_ptr_t). But when @@ -1914,12 +1992,12 @@ namespace boost ::boost::type_traits::ice_and< ::boost::type_traits::ice_eq::value, ::boost::type_traits::ice_or< - ::boost::is_same::value, - ::boost::is_same::value, - ::boost::is_same::value + ::boost::is_same::value, + ::boost::is_same::value, + ::boost::is_same::value >::value >::value, - is_same::value + is_same::value >::value); const bool requires_stringbuf = @@ -1928,14 +2006,18 @@ namespace boost is_stdstring::value, is_arithmetic::value, ::boost::type_traits::ice_and< - is_pointer::value, - is_char_or_wchar::value, + is_char_iterator_range::value, + is_char_types_match + >::value, + ::boost::type_traits::ice_and< + is_pointer::value, + is_char_or_wchar::value, is_char_types_match >::value >::value ); - detail::lexical_stream_limited_src + detail::lexical_stream_limited_src interpreter(buf, buf + src_len); Target result; diff --git a/perf/performance_test.cpp b/perf/performance_test.cpp index ff1eb1d..8640bc4 100644 --- a/perf/performance_test.cpp +++ b/perf/performance_test.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include // File to output data @@ -74,6 +75,12 @@ struct structure_sscanf { OutT out_val; sscanf(in_val.c_str(), conv, &out_val); } + + template + static inline void test(BufferT* /*buffer*/, const boost::iterator_range& in_val, const char* const conv) { + OutT out_val; + sscanf(in_val.begin(), conv, &out_val); + } }; struct structure_fake { @@ -255,6 +262,12 @@ struct to_schar_conv { } }; +struct to_iterator_range { + boost::iterator_range operator()(const char* const c) const { + return boost::make_iterator_range(c, c + std::strlen(c)); + } +}; + int main(int argc, char** argv) { BOOST_ASSERT(argc >= 2); std::string output_path(argv[1]); @@ -296,11 +309,13 @@ int main(int argc, char** argv) { string_like_test_set("char*"); string_like_test_set("unsigned char*"); string_like_test_set("signed char*"); + string_like_test_set("iterator_range"); perf_test("int->int", 100, ""); perf_test("float->double", 100.0f, ""); perf_test("char->signed char", 'c', ""); + fout << "]\n" << "[endsect]\n\n"; return 0; diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 019c9e7..131fa3e 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -45,5 +45,6 @@ test-suite conversion gcc-4.5:-fno-exceptions gcc-4.6:-fno-exceptions ] + [ run lexical_cast_iterator_range_test.cpp ../../test/build//boost_unit_test_framework/static ] ; diff --git a/test/lexical_cast_iterator_range_test.cpp b/test/lexical_cast_iterator_range_test.cpp new file mode 100644 index 0000000..7afb1ae --- /dev/null +++ b/test/lexical_cast_iterator_range_test.cpp @@ -0,0 +1,189 @@ +// Unit test for boost::lexical_cast. +// +// See http://www.boost.org for most recent version, including documentation. +// +// Copyright Antony Polukhin, 2012. +// +// Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt). + +#include + +#if defined(__INTEL_COMPILER) +#pragma warning(disable: 193 383 488 981 1418 1419) +#elif defined(BOOST_MSVC) +#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800) +#endif + +#include + +#include +#include + +using namespace boost; + +#if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING) +#define BOOST_LCAST_NO_WCHAR_T +#endif + +struct class_with_user_defined_sream_operators { + int i; + + operator int() const { + return i; + } +}; + +template +inline std::basic_istream& operator >> (std::basic_istream& istr, class_with_user_defined_sream_operators& rhs) +{ + return istr >> rhs.i; +} + + +template +void do_test_iterator_range(const RngT& rng) +{ + BOOST_CHECK_EQUAL(lexical_cast(rng), 1); + BOOST_CHECK_EQUAL(lexical_cast(rng), 1u); + BOOST_CHECK_EQUAL(lexical_cast(rng), 1); + BOOST_CHECK_EQUAL(lexical_cast(rng), 1u); + BOOST_CHECK_EQUAL(lexical_cast(rng), 1); + BOOST_CHECK_EQUAL(lexical_cast(rng), 1u); + BOOST_CHECK_EQUAL(lexical_cast(rng), 1.0f); + BOOST_CHECK_EQUAL(lexical_cast(rng), 1.0); + BOOST_CHECK_EQUAL(lexical_cast(rng), 1.0L); + BOOST_CHECK_EQUAL(lexical_cast(rng), 1); + +#if defined(BOOST_HAS_LONG_LONG) + BOOST_CHECK_EQUAL(lexical_cast(rng), 1u); + BOOST_CHECK_EQUAL(lexical_cast(rng), 1); +#elif defined(BOOST_HAS_MS_INT64) + BOOST_CHECK_EQUAL(lexical_cast(rng), 1u); + BOOST_CHECK_EQUAL(lexical_cast<__int64>(rng), 1); +#endif + +#ifndef BOOST_LCAST_NO_WCHAR_T + BOOST_CHECK(lexical_cast(rng) == L"1"); +#endif +} + +void test_char_iterator_ranges() +{ + typedef char test_char_type; + + // Zero terminated + test_char_type data1[] = "1"; + iterator_range rng1(data1, data1 + 1); + do_test_iterator_range(rng1); + BOOST_CHECK_EQUAL(lexical_cast(rng1), "1"); + + const test_char_type cdata1[] = "1"; + iterator_range crng1(cdata1, cdata1 + 1); + do_test_iterator_range(crng1); + BOOST_CHECK_EQUAL(lexical_cast(crng1), "1"); + + // Non zero terminated + test_char_type data2[] = "11"; + iterator_range rng2(data2, data2 + 1); + do_test_iterator_range(rng2); + BOOST_CHECK_EQUAL(lexical_cast(rng2), "1"); + + const test_char_type cdata2[] = "11"; + iterator_range crng2(cdata2, cdata2 + 1); + do_test_iterator_range(crng2); + BOOST_CHECK_EQUAL(lexical_cast(crng2), "1"); +} + +void test_unsigned_char_iterator_ranges() +{ + typedef unsigned char test_char_type; + + // Zero terminated + test_char_type data1[] = "1"; + iterator_range rng1(data1, data1 + 1); + do_test_iterator_range(rng1); + BOOST_CHECK_EQUAL(lexical_cast(rng1), "1"); + + const test_char_type cdata1[] = "1"; + iterator_range crng1(cdata1, cdata1 + 1); + do_test_iterator_range(crng1); + BOOST_CHECK_EQUAL(lexical_cast(crng1), "1"); + + // Non zero terminated + test_char_type data2[] = "11"; + iterator_range rng2(data2, data2 + 1); + do_test_iterator_range(rng2); + BOOST_CHECK_EQUAL(lexical_cast(rng2), "1"); + + const test_char_type cdata2[] = "11"; + iterator_range crng2(cdata2, cdata2 + 1); + do_test_iterator_range(crng2); + BOOST_CHECK_EQUAL(lexical_cast(crng2), "1"); +} + +void test_signed_char_iterator_ranges() +{ + typedef signed char test_char_type; + + // Zero terminated + test_char_type data1[] = "1"; + iterator_range rng1(data1, data1 + 1); + do_test_iterator_range(rng1); + BOOST_CHECK_EQUAL(lexical_cast(rng1), "1"); + + const test_char_type cdata1[] = "1"; + iterator_range crng1(cdata1, cdata1 + 1); + do_test_iterator_range(crng1); + BOOST_CHECK_EQUAL(lexical_cast(crng1), "1"); + + // Non zero terminated + test_char_type data2[] = "11"; + iterator_range rng2(data2, data2 + 1); + do_test_iterator_range(rng2); + BOOST_CHECK_EQUAL(lexical_cast(rng2), "1"); + + const test_char_type cdata2[] = "11"; + iterator_range crng2(cdata2, cdata2 + 1); + do_test_iterator_range(crng2); + BOOST_CHECK_EQUAL(lexical_cast(crng2), "1"); +} + +void test_wide_char_iterator_ranges() +{ +#ifndef BOOST_LCAST_NO_WCHAR_T + typedef wchar_t test_char_type; + + // Zero terminated + test_char_type data1[] = L"1"; + iterator_range rng1(data1, data1 + 1); + do_test_iterator_range(rng1); + + const test_char_type cdata1[] = L"1"; + iterator_range crng1(cdata1, cdata1 + 1); + do_test_iterator_range(crng1); + + // Non zero terminated + test_char_type data2[] = L"11"; + iterator_range rng2(data2, data2 + 1); + do_test_iterator_range(rng2); + + const test_char_type cdata2[] = L"11"; + iterator_range crng2(cdata2, cdata2 + 1); + do_test_iterator_range(crng2); +#endif + + BOOST_CHECK(true); +} + +unit_test::test_suite *init_unit_test_suite(int, char *[]) +{ + unit_test::test_suite *suite = BOOST_TEST_SUITE("lexical_cast. Testing conversions using iterator_range<>"); + suite->add(BOOST_TEST_CASE(&test_char_iterator_ranges)); + suite->add(BOOST_TEST_CASE(&test_unsigned_char_iterator_ranges)); + suite->add(BOOST_TEST_CASE(&test_signed_char_iterator_ranges)); + suite->add(BOOST_TEST_CASE(&test_wide_char_iterator_ranges)); + + return suite; +}