Boost logo

Boost Users :

Subject: Re: [Boost-users] Iterator Range, sub range of a desired size
From: Neil Groves (neil_at_[hidden])
Date: 2012-10-31 05:11:41


On Tue, Oct 30, 2012 at 11:03 PM, David Kimmel <davidwkimmel_at_[hidden]>wrote:

> Understood. I was just wondering if the two issues you raised about using
> distance hinted at a possible better solution.
>
>
If one needs to solve this for iterators that are not random access I see
two approaches:
1. Augment your container structure that produces the initial range to
track the distance between the range you are building. This might or might
not make any sense at all depending on the container and the requirements
upon the sub-range.
2. Augment/wrap the iterators so that the wrapped iterator satisfies more
requirements than a ForwardIterator by being able to calculate the distance
in O(1). This can be achieved by maintaining an additional index. The
wrapped iterator would still not model the RandomAccessIterator Concept
since it would not need to provide O(1) advance etc.

Each of these is probably too much additional work until a concrete
use-case presents itself.

Yes, at this point though the solution (make_iterator_range, next,
> distance, with two ranges) completely satisfies the problem. It is
> definitely a RandomAccessRange type problem.
>
> Sweet.

> Thanks to everyone.
>
>
You are very welcome. Thanks for your patience with my slow understanding
of the problem.

Regards,
Neil Groves



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net