Boost logo

Boost :

From: Bill Seymour (bill-at-the-office_at_[hidden])
Date: 2002-11-05 09:15:51

Daryle Walker wrote:
> Instead of operator<<(ostream,rounding) returning a special object
> for later use in operator<<(special,decimal), which doesn't persist
> between statements, why don't you do something like the std::width
> conspiracy? The standard I/O flags are sticky, but the non-
> stickiness of std::width is done by a conspiracy that operator<<
> always resets the width after an output.

It's not really the stickiness or lack of it that concerns me;
indeed, I think I'd prefer the rounding mode to be sticky.

The problem is how to store the rounding mode, a pointer to
a function, for subsequent calls of the << and >> operators.
If it's stored in some global variable, then we have even more
serious thread safety issues than we have now. We could use
ios_base::pword(); but there's no guarantee that a void(*)()
can make the round trip conversion to void*, so we'd have to
allocate memory for a void(*)() and have all the complications
of checking for a null pointer and making sure the pointer
gets deallocated when necessary.


Boost list run by bdawes at, gregod at, cpdaniel at, john at