
Jeremy Maitin-Shepard wrote:
"Edward Diener" <eddielee@tropicsoft.com> writes:
[snip]
This can probably even be:
std::string msg((std::ostringstream() << "There have been " << users << "users logged on so far").str());
Unfortunately this is not possible, because operator<< returns a basic_ostream reference, not a stringstream reference.
OK, I see, Doing an .str() on a basic_ostream reference won't work. Maybe: std::string msg((dynamic_cast<const std::ostringstream &>(std::ostringstream() << "There have been " << users << "users logged on so far")).str()); but it begins to look a but ugly.
I have to admit that I don't understand any of the reasons for using printf... functions or boost::format instead of the C++ string streams. The latter seem much more natural and easier to me, and are further supported by boost::lexical_cast to make trivial conversions to and from strings even easier.
Refer to my other posting for information on why printf-like mechanisms significantly aid translation. Using the stringstream mechanism, translation requires modifying the source code, which is not at all practical.
OK, I haven't done much language or locale translation so I have no strong opinion either way. I do see that printf like strings, with their embedded % identifiers can be translated whole, whereas stream strings are often made of fragments combined.