On 12/19/06, me22 wrote:
On 12/18/06, Phil Endecott
wrote: Surely, since I have asked for %d in the format string, format() can do the cast? i.e. something like (PSEUDOCODE)
I'm not convinced that having it act like stringstream and lexical cast is a bad thing. Using a uint8_t in a situation where its numerical value would often be output in textual representation also smells of unnecessary size optimization, to me.
OTOH, "This class's goal is to bring a better, C++, type-safe and type-extendable printf equivalent to be used with streams." (http://boost.org/libs/format/doc/format.html#rationale) Being equivalent means that it should "provide printf-compatibility, as much as it makes sense in a type-safe and type-extendable context." (http://boost.org/libs/format/doc/format.html#rationale) Given the above stated goals of boost::format, the following should be equivalent unless that wouldn't make sense. [quoted from OP] uint8_t i = 65; printf("i = %d\n",i); uint8_t i = 65; cout << boost::format("i = %d\n") % i; I don't see any reason why it wouldn't make sense for these to be equivalent, so I think they should be. If someone does have a reason why it wouldn't make sense, then that reason should be added to the rationale section of the documentation, as the current behavior goes counter to a very reasonable expectation. -- Todd Greer