Boost logo

Boost Users :

From: Jason Nye (jnye_at_[hidden])
Date: 2006-08-09 15:22:32


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

 



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net