istream behavior change in C++ upon failure

It seems as originally specified, the operator>>s were broken in some cases (i.e. strictly speaking couldn’t exist).
This is the “fix”.

In a draft from early 2011, The Standard is basically the same in this regard as it was in 2003. However, in a library defect report opened by Matt Austern (in 1998!), num_get<>::get() doesn’t exist for short and int.
So they were changed to use the long version, and check the read number falls within the correct range.

The defect report is here.

(Doesn’t really explain why they didn’t think they could keep the originally intended behaviour, but it is why this part of The Standard was changed.)

Leave a Comment