Boost logo

Boost :

From: Zack Weinberg (zackw_at_[hidden])
Date: 2007-03-03 13:49:41


Consider the following example program:

#include <boost/format.hpp>
#include <cstdio>
#include <string>

int main()
{
    unsigned char n = 65;
    std::printf("%u\n", n);
    std::puts((boost::format("%u") % n).str().c_str());
}

$ g++ test.cc
$ ./a.out
65
A

In my opinion this is a bug - both operations should produce "65". I
realize that boost::format by design does not pay much attention to
the format type specifier, but this is the only way to tell whether
someone is using a char-type variable as a character or as an 8-bit
number. I would prefer not to have to insert static_cast<unsigned
int>() everywhere I might print one of these 8-bit numbers.

zw


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk