Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-10-26 11:21:41


From: "Kevin S. Van Horn" <kevin.vanhorn_at_[hidden]>
> On Fri, 26 Oct 2001, Ben Cooling wrote:
>
> > >How about generalizing even further: instead of specifying the end of
> > >range by an iterator, allow an arbitrary function that takes
> > >an iterator
> > >as argument.
> >
> > And a reference to the container, of course.
>
> No, since generic algorithms don't know and shouldn't know about
> containers; they only know about iterator ranges. In some cases, there is
> no container object (input iterators, arrays). As an example of what I'm
> talking about, here's what the copy algorithm would look like:

[interesting generalization]

> or
>
> copy(src, count(n), dst); // copy n characters

But note that algorithms that take ranges don't usually impose any traversal
requirements (in the general case), i.e. they don't travel sequentially
forward from 'first' until a predicate hits (at least conceptually.)

Conceptually, they act on the [first, last) range as a whole, possibly at
the same time.

--
Peter Dimov
Multi Media Ltd.

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