Boost's lexical_cast
converts numbers (or arbitrary objects) to strings and back. Should I try to use it more, say, instead of streaming things to std::stringstream
s? Or is it more of a mechanism-of-last-resort?
Here's one example of two alternative approaches:
std::stringstream message;
message << "foo " << bar << ' ' << baz;
doSomething(message.str());
or
doSomething("foo " + lexical_cast<string>(bar) + " " + lexical_cast<string>(baz));
(but note my question is more general).