So to be on the safe side, I reinstated the requisite defaults. Perhaps there's a better way to do this? A single "reset stream to default" instruction? I haven't used C++ ostream formatting very much so I don't know.
I'm not aware of any one command to return the stream to the default state there are several ways of resetting various settings, for example setf() and unsetf() control the left, right or internal and the dec, oct or hex and scientific or fixed flags.
Another way is to capture the previous settings before or when you set the values so you can reset the stream to those values:
Code:
std::cout.setf(std::ios::fixed);
int prec = std::cout.precision(2);
out(-1, -1.61803, 0);
out( 1.61803, 0, 1);
std::cout.unsetf(std::ios::fixed);
std::cout.precision(prec);
Another way to get the stream back to the default setting is to create a new stream (any kind of stream will do) and copy the format from this new stream to the stream you want to change back to the default settings.
Code:
std::stringstream ins;
std::cout.copyfmt(ins); // Copy ins's format specifiers to the std::cout stream.
Jim