Boost logo

Boost :

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

From: "Kevin S. Van Horn" <kevin.vanhorn_at_[hidden]>
> > > copy(src, count(n), dst); // copy n characters
> >
> > But note that algorithms that take ranges don't usually impose any
> > requirements (in the general case), i.e. they don't travel sequentially
> > forward from 'first' until a predicate hits (at least conceptually.)
> Yes, it would only be appropriate to use count(n) with algorithms that
> take an input iterator and guarantee to only check for end-of-range once
> before each increment of the iterator.

Not only that. A range allows me to (quickly for random access iterators)
retrieve the middle element, or iterate backwards, while a (first, pred)
construct does not.

For input (and perhaps forward) iterators, a (first, pred) representation is
more convenient; random access (and perhaps bidirectional) iterators like
[first, last).

Peter Dimov
Multi Media Ltd.

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