M
Marc
Hello,
I noticed today that istringstream::str, which changes the underlying
string, does not clear the error state. In particular, if you read a
string to the end then change the string and try to read the new one,
eofbit is still set so it fails. In a similar situation, ifstream:pen
calls clear when you open a new file. Is there a particular reason for
this inconsistency?
int n;
istringstream i("1");
i >> n;
i.str("2");
i >> n; // fails because we still have i.eof()
I noticed today that istringstream::str, which changes the underlying
string, does not clear the error state. In particular, if you read a
string to the end then change the string and try to read the new one,
eofbit is still set so it fails. In a similar situation, ifstream:pen
calls clear when you open a new file. Is there a particular reason for
this inconsistency?
int n;
istringstream i("1");
i >> n;
i.str("2");
i >> n; // fails because we still have i.eof()