Boost logo

Boost Users :

Subject: Re: [Boost-users] Iterator Range, sub range of a desired size
From: Jeff Flinn (Jeffrey.Flinn_at_[hidden])
Date: 2012-10-29 08:50:07


On 10/29/2012 8:14 AM, Thorsten Ottosen wrote:
> On 29-10-2012 08:33, Neil Groves wrote:
>>
>> On Mon, Oct 29, 2012 at 4:40 AM, David Kimmel <davidwkimmel_at_[hidden]
>> <mailto:davidwkimmel_at_[hidden]>> wrote:
>>
>> Is there a function in BOOST, given a starting point and a desired
>> size, that
>> returns iterators for a (sub) range?
>>
>>
>> There are two classes in Boost.Range that achieve this purpose. The
>> first, boost::iterator_range<Iterator> can be used to hold sub-ranges.
>> It is not directly constructible from the form firstIterator, count
>> since this would either require that the Iterator is a model of the
>> RandomAccessConcept or would provide sloppy performance guarantees.
>
> We could consider to add an make_iterator_range which took the count,
> and then make a static assertion about random access iterators. It seems
> to me that iterator + count is a quite normal way of creating a range.
>
> -Thorsten

The 'sliced' adaptor is almost there, with it's begin/end indices.

http://www.boost.org/doc/libs/1_51_0/libs/range/doc/html/range/reference/adaptors/reference/sliced.html

Jeff


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