Boost logo

Boost :

Subject: Re: [boost] [range] RFC: span(iterator, size)
From: TONGARI J (tongari95_at_[hidden])
Date: 2013-10-29 12:25:56


Hi Akira,

2013/10/30 Akira Takahashi <faithandbrave_at_[hidden]>

> Hi,
>
> 2013/10/30 TONGARI J <tongari95_at_[hidden]>
>
> > Hi there,
> >
> > I want to query if there's any interest in such a utility:
> >
> > span(iterator, size) : iterator_range
> >
> > which simply returns iterator_range(it, it + size) for
> > RandomAccessIterator;
> > for others modeling ForwardIterator, a special iterator adaptor, say,
> > counted_iterator is used, so we don't have to advance it just for getting
> > the end iterator.
> >
> >
> > Thoughts?
> >
>
> I & Nail will add `taken` range adaptor.
>
>
> http://dl.dropboxusercontent.com/u/1682460/git/OvenToBoost/libs/range/doc/html/range_extension/reference/range_adaptors/taken.html
>
> https://github.com/faithandbrave/OvenToBoost/blob/master/boost/range/adaptor/taken.hpp
>
> v = {1, 2, 3, 4, 5};
> r | taken(3); // {1, 2, 3}
>
> Also, I have iterator adaptor version (internal).
>

I don't think this is what I want, but the underlying iterator may be
similar to what I called 'counted_iterator', I'm not sure.
So, 'span' is a utility function that generates a range from an iterator &
size, unlike 'taken' which is an adaptor from another range.
If you can provide the 'span' utility as well, that'll be great :)

Thanks,


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk