Standard C++ Library Class Reference
Click on the banner to return to the Class Reference home page.
©Copyright 1996 Rogue Wave Software
advance
Iterator Operation
Summary
Move an iterator forward or backward (if available) by a certain distance.
Contents
Synopsis●
Description●
Example●
Warnings●
See Also●
Synopsis
#include <iterator>
template <class InputIterator, class Distance>
void advance (InputIterator& i, Distance n);
Description
The advance template function allows an iterator to be advanced through a container by some
arbitrary distance. For bidirectional and random access iterators, this distance may be negative.
This function uses operator+ and operator- for random access iterators, which provides a
constant time implementation. For input, forward, and bidirectional iterators, advance uses
operator ++ to provide linear time implementations. advance also uses operator -- with
bidirectional iterators to provide linear time implementations of negative distances.
If n is positive, advance increments iterator reference i by n. For negative n, advance