Boost logo

Boost :

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

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

> 2013/10/30 TONGARI J <tongari95_at_[hidden]>
> > Hi Akira,
> >
> > 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,
> fmm...
> What do you think about out of range check?

I'd say, it's the user's duty to ensure it won't go over the end.

> What situation is it useful?

When you want to ignore the difference between RandomAccessIterator &
ForwardIterator while keeping the efficiency of RandomAccessIterator.

Some API may look like this: function(iterator, n, ...)
that only require iterator to be ForwardIterator, but the implementation
may sacrifice the efficiency of RandomAccessIterator, just because the
implementor doesn't want to bother tag-dispatching for such optimization...
(OK, I'm the one)

Boost list run by bdawes at, gregod at, cpdaniel at, john at