Does the C++ Standard Library define this function, or do I have to resort to Boost?
I searched the web and couldn't find anything except Boost, but I thought I'd better ask here.
Does the C++ Standard Library define this function, or do I have to resort to Boost?
I searched the web and couldn't find anything except Boost, but I thought I'd better ask here.
No it's a pure Boost thing only.
If you don't want boost then a lightweight library called fmt implements the following:
More examples from the official page.
Accessing arguments by position:
Aligning the text and specifying a width:
Replacing %+f, %-f, and % f and specifying a sign:
Replacing %x and %o and converting the value to different bases:
No it isn't, even in C++11, but it's proposed for inclusion in Technical Report 2, the next set of std library extensions.
There's no std::lexical_cast, but you can always do something similar with stringstreams:
Only partially.
C++11
<string>
hasstd::to_string
for the built-in types:There are also the following that go the other way around:
However, there's nothing generic that you can use (at least not until TR2, maybe!), and nothing at all in C++03.