Class template counted_iterator is an iterator adaptor
with the same behavior as the underlying iterator except that
it keeps track of the distance to the end of its range.
It can be used together with default_sentinel
in calls to generic algorithms to operate on
a range of N elements starting at a given position
without needing to know the end position a priori.
[Example 1: list<string> s;
// populate the list s with at least 10 strings
vector<string> v;
// copies 10 strings into v:
ranges::copy(counted_iterator(s.begin(), 10), default_sentinel, back_inserter(v));
— end example]
Two values i1 and i2 of types
counted_iterator<I1>
and
counted_iterator<I2>
refer to elements of the same sequence if and only if
next(i1.base(), i1.count())
and
next(i2.base(), i2.count())
refer to the same (possibly past-the-end) element.