Boost logo

Boost :

Subject: Re: [boost] lifetime of ranges vs. iterators
From: David Abrahams (dave_at_[hidden])
Date: 2008-09-06 19:32:04


on Sat Sep 06 2008, Arno Schödl <aschoedl-AT-think-cell.com> wrote:

>> > increment() {
>> > for( difference_type i=0; i<N && !base.empty(); ++i ) {
>> > base.increment(); // the adapted_range::increment which increments begin,
>> > base is a range
>> > }
>> > }
>
>> I don't think you're fully appreciating what a huge impact such a
>> complex implementation of increment() would have on performance.
>
> Sorry, I meant this as the implementation for forward range. You don't want to
> use increment for random_access ranges, obviously.

I don't see what the traversal category has to do with anything.

> Thinking about it some more, I believe the associated_range abstraction is not
> quite the right one yet. It works for forward_ranges, which is why I did not
> notice earlier, but not for bidirectional and random_access_ranges.
>
> The correct abstration is bounded_iterator, which is an iterator + the knowledge
> of whatever bounds it needs.

Only if you don't care about eliminating other redundancies.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

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