Subject: Re: [boost] AlRangeExandrescu?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-07-24 15:13:12
Stewart, Robert wrote:
> You said all ranges can be expressed as a pair of iterators. I
> claimed some ranges don't have a predetermined end, so can't be
> expressed as a pair of iterators. Dave Abrahams correctly noted
> that it is possible to make an iterator that takes a predicate
> and, I infer, becomes the end iterator once the range indicated
> by the predicate has been traversed. Reversing said iterator
> might be a bit harder.
> How about another try: traversing a range with changing criteria?
> A particular range class can take a predicate or some other
> traversal influencing argument that can change with each
> advance. How would you express that with iterator pairs?
Easily. First of all, consider what's possible if the two iterators
are allowed to be different types. Then all the actual state can
be put in the first iterator and comparison to the second iterator
can just check whether the range is empty. Once you have that,
you can use boost::variant to store both iterators as the same type.
This will not be efficient, but it will work.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk