Boost logo

Boost :

From: Corwin Joy (cjoy_at_[hidden])
Date: 2001-08-10 02:00:05


----- Original Message -----
From: "John E. Potter" <jpotter_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Thursday, August 09, 2001 5:17 PM
Subject: Re: [boost] (infinite) sequences using recurrence relations

>
>
> On Thu, 9 Aug 2001, John Maddock wrote:
>
> > Not just operator++, operator* effectively invalidates all copies of an
> > iterator (or at least leaves them in an undefined state), that's why
there
> > is a requirement that calls to operator* and operator++ must alternate.
>
> Make that output_iterator and we can agree that we must use sequences
> of the pair *it= and ++it (alias *it++=).
>
> > (OK
> > that's not what the standard says - it says that algorithms must be
"single
> > pass algorithms" and that they can not pass through the same iterator
> > twice, dereferencing without incrementing counts as a double pass IMO).
>
> Our disagreement. IMO you have not passed *through* an iterator until
> it is incremented. When you come *to* an iterator value, you may stay
> there and dereference it many times. Once you go through (increment)
> it, there is no way back to it, ie. copies are invalid.
>
I'm with potter here, I would consider it extremely surprising if you were
to dereference a particular iterator twice without any intervening
operations and
got a different result. Having said that, there is the part of the
standard in table 72:
++r: postcondition-- "any copies of the previous value of r are no longer
required
to be dereferenceable or to be in the domain of ==". So, it is possible
that
*i; ++j; *i;
the second call to *i might not return a value at all after an intervening
increment on
another iterator if i is a copy of that iterator.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk