Boost logo

Boost :

From: Arno Schödl (aschoedl_at_[hidden])
Date: 2008-08-29 11:21:31

David says:

>I've been trying to say that generic algorithms *can't* worry about the
>range lifetime; they have to assume that the iterators they're passed
>will not be invalidated before they're destroyed. ...
>Bleah (sorry). Iterators in general shouldn't be burdened with the
>requirement to know the limits of the sequence, and if you go back and ...
>My advice: make sure you keep in mind the whole problem domain. You can't
>understand the reason that C++ iterators are unlike those in other languages
>without looking at the algorithms.

What you are saying about iterators is all true, and they work wonderfully. The problem that you acknowledged, which is exactly the problem that I have when designing difference_range, is that a _pair_ of iterators often has redundant information, which in the case of stacking difference_ranges leads either to storage bloat or to storage lifetime issues because we need a place to store this redundant information. The universal end iterator fixes this problem for forward ranges, but not for bidirectional or random access ranges.

Giovanni says:

>Anyways, the solution is simple: if you want your adaptor to survive the original wrapped range, you have >to store a copy of the wrapped range in the adaptor. As an added benefit, the adaptor size will be the >smallest possible for deep sequences of stacked adaptors.

This is a good solution, but RangeEx is not designed that way, and it is a big departure from regular containers. I am happy with it if we decide that this is the way to push for the next C++ standard:-)


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