This all works pretty nice, but I am having trouble with "std::showbase" and "std::internal". (as in "0x000000a7" instead of "a7")
Because what I am returning to the stream is actually an std::string, I have to emulate their behavior by hand, by hand-inserting the base, then inserting in between the internal padding, the inserting the string into the stream. I gives me something like this:
So anyways, that's how I do it. Is there a way to avoid all the above? Not only is it a bit hackish, I'm not even sure all platforms use "0x" and "0" as base prefix, and overall, doesn't look very portable. Finally, there are probably a bunch of flags I am miss-handling/forgetting.
Would it be possible to insert a string into the stream, but somehow tell the stream it should treat it as a number, and let it take care of the rest (padding, base etc)?