Boost logo

Boost :

Subject: Re: [boost] AlRangeExandrescu?
From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2009-07-25 04:42:34

Thorsten Ottosen wrote:
> Andrei Alexandrescu skrev:
>> A design that has a bidirectional iterator walking freely up and down
>> between two limits would be difficult to port to ranges. (If the
>> iterator is random-access, things are trivial.) Ranges can only
>> shrink, they never grow unless assigned from the outside. So when you
>> move one direction it would be difficult to grow one range (shrinking
>> the other is easy). That design would benefit from letting the
>> iterator abstraction exposed.
> Couldn't it be done with a special range that stores three iterators?
You could introduce SplittableRange, which has four additional primitives:

splitpoint_advance: Move split point one step towards end.
Throw/abort/nasal demons if it's already there.
splitpoint_retreat: Move split point one step towards begin. See above.
front: Return the range between begin and split point.
rear: Return the range between split point and end.

A special range that stores three iterators would be an implementation
possibility. For random-access iterators, you can also use two iterators
and an index, and there should be a range adapter that converts any
random-access range into a splittable range.


Boost list run by bdawes at, gregod at, cpdaniel at, john at