|
![](/i/fill.gif) |
Warp wrote:
> MyType value = something;
> std::cout << "The value is: " << value << "\n";
Here's something I've been wondering about that. Say you have your own
type, and you want a set of flags like hex/oct/decimal or setfill or
something like that. I.e., you want to be able to say
std::cout << prettyprintindent(4) << myvalue << "\n";
Where does the "4" there get stored? And how can you make it so that
(say) passing -1 puts back what it was before the previous call for the
same stream? It would seem that you'd need some sort of data structure
mapping streams to pretty print indent levels, yes? And no automated way
of cleaning that up with a destructor?
What am I missing here?
Incidentally, I've seen the problem with printf that you're talking
about here solved by doing something like this:
typedef long MyInt;
#define MyIntPrintf "%l"
Then, you write something like
MyInt counter;
printf("I counted " MyIntPrintf " instances\n", counter);
so it's really not that much harder to change, if at all.
--
Darren New / San Diego, CA, USA (PST)
"That's pretty. Where's that?"
"It's the Age of Channelwood."
"We should go there on vacation some time."
Post a reply to this message
|
![](/i/fill.gif) |