advance function template — Moves iterator forward or backward
template <typename InputIterator, typename Distance>
void advance(InputIterator& i, Distance n);
The advance
function
template advances an input iterator i
by a distance n
. If the iterator is bidirectional or
random access, n
can be negative.
If the iterator is random access, the advance
function is specialized as
i
+
n
;
other iterators apply the ++
operator n
times (or --
for a bidirectional iterator when
n
is negative).