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? —John
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
On 6/26/2011 6:40 PM, Szymon Gatner wrote:
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
Putting it at the beginning is pretty much the same as putting it at the end.
participants (2)
-
John M. Dlugosz
-
Szymon Gatner