26 Jun
2011
26 Jun
'11
11:40 p.m.
2011/6/27 John M. Dlugosz
I brought this up a while back, and I ran into it again yesterday. Using boost::format to produce a string, as opposed to sending it directly to cout, is awkward.
boost::format ("blah blah blah") % exp1 % exp2 %exp3
is fine in and of itself. But then what? You need to wrap the whole thing in extra parens to use str:
std::string s= (boost::format ("blah blah blah") % exp1 % exp2 %exp3).str();
WHY NOT allow implicit conversion to string?
Or, some other mechanism that doesn't complicate the expression and bury the interesting part?
use str() free function: std::string s = str(boost::format ("blah blah blah") % exp1 % exp2 %exp3) same when passing format to functions taking std::string params Szymon