This does what I want:
uint8_t i = 65; printf("i = %d\n",i); [snip] uint8_t i = 65; cout << boost::format("i = %d\n") % i;
But it seems to have the same, unwanted, behaviour as cout<
cout << "i = " << static_cast<unsigned int>(i) << "\n";>
You can just cast the value to an int
Yes, as I mentioned towards the end of my message. But I find that obfuscated. It's particularly problematic when the value is a field in a struct whose type I don't exactly remember, and I forget the need to cast it; the result is control characters being written to the terminal, which can be hard to debug. Surely, since I have asked for %d in the format string, format() can do the cast? i.e. something like (PSEUDOCODE) template <typename T> operator%(T val) { .... if (format_char='d') int val1 = static_cast<int>(val) ... } or have I missed some additional complexity? Phil.