incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: another istream_iterator question
Date Wed, 07 Nov 2007 15:50:09 GMT
Mark Brown wrote:
> I have been looking at the istream_iterator class, mostly out of
> curiosity than to try to fix a specific bug, to see if there are
> any other discrepancies with the standard and operator++ caught
> my attention. The standard says that the operator should return
> *in_stream >> value but the stdcxx definition looks like this:
> 
>     istream_iterator& operator++ () {
>         return _C_strm && !!*_C_strm && (*_C_strm >> _C_val), *this;
>     }
> 
> There are two extra checks that aren't required by the standard.
> They are probably harmless but I wonder if they shouldn't be
> removed for efficiency. Does anyone see a problem with such
> a change?

I see no problem with it. We should assert that _C_strm is non-null
before dereferencing it but other than that I see no reason to try
to prevent undefined behavior (the effects of operator++ are
undefined once the iterator has reached the end of the sequence).

Martin

> 
> --Mark
> 


Mime
View raw message