Quick: Would you resort to stringstream? But that's so C++98... and so hard.
More people need to know about
to_string and its cousins. Marius Bancila takes us for a short tour:
by Marius Bancila
From the article:
C++11 provides several standard functions for converting numbers to strings and strings to numbers, all of them available in the
For converting numbers to strings there are two new overloaded functions:
to_wstring(). They take one argument of various numeric types (
long double, etc.) and return either a
std::wstringwith the number converted to text. ...
For the other way around of converting strings to numbers there are several overloaded methods (taking either a