boost::format - incorrect (printf-incompatible) handling of "%u" with characters

3 Mar
2007
3 Mar
'07
6:49 p.m.
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
6677
Age (days ago)
6677
Last active (days ago)
0 comments
1 participants
participants (1)
-
Zack Weinberg