Boost logo

Boost :

From: Arno Schödl (aschoedl_at_[hidden])
Date: 2008-08-31 17:59:31

> > How is the separation of common_data and unique_data different from a separation
> > of ranges and iterators? If iterators of ranges can rely on their range to
> > exist, this is where common data like functors, end iterators etc. can be
> > stored.

> Naturally the point is to store the common data once when you need to
> store more than one iterator to the same sequence -- in a range, for
> example.

> If you're asking why I bother reconstituting the whole iterator out of
> its parts, instead of simply referring to the common_data stored in the
> range: an adapted iterator is a useful concept regardless of whether
> anyone is using a range abstraction.

You could provide an adapted_iterator and also an adapted_range. If we subscribe to the rule that ranges must stay valid for their iterators to be valid, the adapted_range::iterator can use the common data stored in the range, while the adapted_iterator stores the common data itself. Both could even be derived from the same source code. Do you then still need a factored iterator?

Or do you want to avoid people having to use the range abstraction? If you pass iterator pairs to algorithms instead of ranges, at least this parameter passing would have to pass the common data redundantly, even if inside the algorithm, say when many iterators have to be stored, the common data is stripped and stored separately.

Dr. Arno Schoedl · aschoedl_at_[hidden] 
Technical Director 
think-cell Software GmbH · Invalidenstr. 34 · 10115 Berlin, Germany · phone +49-30-666473-10 · toll-free (US) +1-800-891-8091
Directors: Dr. Markus Hannebauer, Dr. Arno Schoedl · Amtsgericht Charlottenburg, HRB 85229

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