|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2004-07-11 22:18:07
David Abrahams <dave_at_[hidden]> writes:
> I'm getting ready to fix the issues we've discussed with postfix ++
> (and by extension, --) in iterator_facade. Basically, the current
> implementation works for forward iterators but not for some input
> iterators:
>
> {
> self x = *this;
> ++*this; // <== here
> return x;
> }
>
> The problem is that for many input iterators, all copies reference the
> same element. The marked line increments the iterator, which causes
> the current element of the sequence to be skipped, so
>
> *a++
>
> yields the /next/ element. To fix that, a++ needs to return a proxy
> type.
Fixed now in CVS, along with new tests.
-- Dave Abrahams Boost Consulting http://www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk