Boost logo

Boost :

From: Noel Yap (yap_noel_at_[hidden])
Date: 2002-05-20 08:13:18


--- David White <dave_at_[hidden]> wrote:
> Well, it "drops in" to the STL algorithms equally
> well to the existing
> distance function. An alternative though, which
> allows more interaction
> with STL algorithms is to have an iterator adapter
> that I call
> iterator_n, it takes an index as a parameter, along
> with the iterator,
> it moves the index every time the iterator is moved,
> and is defined to
> compare two iterators as equal if the underlying
> iterators are equal, or
> if the indexes are equal.
>
> for example:
>
>
distance(iterator_n(o.begin(),0),iterator_n(o.end(),5));
>
> would have the same functionality as the distance_n
> provided. (The index
> parameter could be defaulted to 0, and so would be
> unnecessary for the
> first one). Further, one could do the following:
>
>
copy(iterator_n(o.begin()),iterator_n(o.end(),5),buffer);
>
> to copy at most 5 elements to buffer. I would find
> something like this
> fairly useful in a number of areas.

Currently, I've created a function copy_n that copies
at most 'n' elements. I can see other '_n' type
functions. iterator_n would make such functions moot
so iterator_n would be a great addition to Boost. Is
there an effort to add this into Boost?

Thanks,
Noel

__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com


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