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-29 03:33:19


On Mon, Oct 29, 2012 at 4:40 AM, David Kimmel <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. This behaviour is easily
achieved by constructing the iterator_range with
boost::make_iterator_range(boost::next(buffer.begin(), 4), buffer.end()).
Additionally there is the boost::sub_range<Range> which is very similar to
iterator_range except that it preserves const-ness of the parent range.

http://www.boost.org/doc/libs/1_51_0/libs/range/doc/html/range/reference/utilities/iterator_range.html
http://www.boost.org/doc/libs/1_51_0/libs/range/doc/html/range/reference/utilities/sub_range.html

>
>
> Thanks,
>
> 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