On Feb 8, 1:15 pm, Victor Bazarov <v.baza...@comcast.invalid> wrote:
> On 2/8/2012 12:16 AM, Chris Stankevitz wrote:
>
> Use 'printf', it seems to suit *this particular task* better.
But sometimes you want to mix streaming objects with a custom
operator<< with printing hex values of bytes. Are you suggesting
interleaving
std::cout << complex_object;
printf("%x",byte);
and hope that buffering makes that OK?
Alternatively, you may want to serialise some bytes to a
std::stringstream or serialise some bytes to a stream provided by a
library user as a std::ostream& arguments, or to a file which has been
opened as an std::fstream ... or ... or ...
fprintf is fine, if you're writing to a C-style FILE*.
It's useless for anything else, and there are *plenty* of anything-
elses.
The standard stream-formatting API is an bloody disaster area, so full
of gotchas and weirdness as to be almost-unusable. Boost::Format is
the solution.