Invalid version of old acceleration.
The result of lexical_cast should be the same as the streaming in ostream. Thus, the result
std::cout << boost::lexical_cast<std::string>(x)
coincides with
std::cout << x
In the case of unsigned char this means interpreting x as an ASCII code, for other integer types it will give the same result as itoa . This is because char types are not considered upstream arithmetic integers (see Β§ 27.3.6.2 and Β§ 27.3.6.4). The advantage of this approach is that you can output a string by printing its individual characters. If you want an actual numeric value, you can always make char an arithmetic type for output.
to_string , on the other hand, works like itoa for all integer data types, since it has no overload for unsigned char . The rationale here is that by calling to_string , you have already expressed your intention to perform the conversion, that is, you are not interested in the quality of the character quality values ββ(which would be the default), but arithmetic type quality.
source share