[PATCH] Cleanup in istream.tcc
Pétur Runólfsson
peturr02@ru.is
Wed Sep 24 12:38:00 GMT 2003
Martin Sebor wrote:
> Also, even when failbit is already set prior to the call to the
> sentry ctor, whether the input function does or does not call
> setstate(failbit) is detectable simply by setting failbit in
> exceptions. AFAIK, the standard doesn't say whether input
> functions must call setstate(failbit) if the bit is already
> set. I suspect that it was not even considered when exceptions
> were added to iostreams. I would like to see this specified
> more precisely.
I see that there is now a defect report about this (419).
I mostly agree with the proposed resolution, except for this:
> I think I like the first alternative better (i.e., there's no reason
> to call setstate(failbit) if the bit is already known to be set).
It seems more consistent to always set failbit if !good(). If
both failbit and badbit are set in exceptions,
is >> x;
will either succeed or throw an exception, and x can be used after
the call without first checking is.fail().
> In particular, readsome() is explicitly required to set failbit when
> the sentry is false.
This is an even better reason that the resolution of 419 should
be to always setstate(failbit) if !good(), otherwise the behaviour
of readsome() will differ from the other input functions.
Petur
More information about the Libstdc++
mailing list