As stated in the [ostream.inserters.character]
section of the C++ standard, after a char
or string is inserted into a stream the stream's width is set to 0:
template<class traits>
basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out,
const unsigned char* s);
Do lots of sensible and expected things...
Calls width(0).
Why does the C++ standard dictate a call to width(0)
?
What is the rational for changing the streams width and not reseting it to its original value? (As far as I know all other properties of a stream are preserved by the stream insertion operators.)
There is a related question here, which demonstrates the confusion this causes, but does not explain why the standard dictates this behavior.