I’m doing:
string myString = (boost::format(“%i”) % 1.1).str();
I would expect that to either throw an error (preferred) or cast to an int and then format. I’m seeing a similar issue with %x and %o etc. Any thoughts?
According to the Boost.Format documentation [1], the effect of the %i format specifier is to output its argument in a decimal base, not to force it to be an integer. There appears to be no way to specify in the format string that an argument should be coerced to be an integer, or that an exception should be thrown if it's not. The idea behind a strongly-typed formatting library is that the information about the types of the arguments is contained in, well, the types of the arguments, not in the format string. The format string is used to specify additional information that is not encoded in the type of the argument, like the base. Regards, Nate [1] http://www.boost.org/doc/libs/1_54_0/libs/format/doc/format.html#printf_dire...