Boost logo

Boost :

From: Samuel Krempp (krempp_at_[hidden])
Date: 2005-03-31 01:22:32

Vladimir Prus wrote:

>Martin Bonner wrote:
>>>While it's generally considered a bad practice to provide implicit
>>>conversions, I think it would be good to provide such a conversion
>>>for the boost::format class.
>>Having been bit far too many times by bad implicit conversions, I would
>>against such a change. I don't see why one shouldn't pass in a format
>>object to a function (possibly for the function to add one argument to the
>>format object).
>And for implicit conversion to do any harm, you need to mistakenly pass
>boost::format to a function which takes std::string, right? In this case,
>boost::format will immediately throw and you'll detect the bug in no time.
The problem I find more concerning is implicit conversions caused by
typo in operators

s = format("name=%1 processed") % s1 + s2;

if format is convertible to string, the type of s2 here might be such
that this line compiles (e.g. s2 of type string), so such typos could go
unnoticed for a while..
My opinion was it's safe to use operators for format as long as it is
not implictly-convertible.
it's true that using a str free function can be a nuisance.


Boost list run by bdawes at, gregod at, cpdaniel at, john at