Hello all,

 

I’m having trouble with boost format and precision specifiers with strings. The problem is that if I don’t specify the ‘s’ in the format string, a precision specifier does not truncate the string as I would expect:

 

format(“%.4s”) % some_string

 

The above will truncate some_string to the first four chars.

 

            format(“%|.4s|”) % some_string

 

Same thing. However, the following does not truncate:

 

            format(“%|.4|”) % some_string

 

This is confusing because the biggest boon to using boost::format for me is that the type specifier is (I thought) unnecessary. I would think that format would see the .4 and use that as precision if a floating point value was provided and use it as the length of the string if a string was provided.

 

Is this a bug or is this the intended behavior?

 

Thanks!

Jason.

 

If you have a procedure with ten parameters, you probably missed some.

 

--Alan Perlis