Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Standard C++ Library Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

advance()

Module:  Standard C++ Library   Library:  Iterators


Function

Local Index

No Entries

Summary

A function that advances an iterator forward or backward (if available) by a certain distance

Synopsis

#include <iterator>

namespace std {
  template <class InputIterator, class Distance>
  void advance(InputIterator& i, Distance n);
}

Description

The advance() function template allows an iterator to be advanced through a container by some arbitrary distance. For bidirectional and random access iterators, this distance may be negative. For random access iterators, this function uses operator+=() and operator-=() for constant time implementations. For input, forward, and bidirectional iterators, advance() uses operator++() for linear time implementations. advance() also uses operator--() with bidirectional iterators for linear time implementations of negative distances.

If n is positive, advance() increments iterator reference i by n. For negative n, advance() decrements reference i. Remember that advance() accepts a negative argument n for random access and bidirectional iterators only.

Example

See Also

Sequences, Random Access Iterators, distance()

Standards Conformance

ISO/IEC 14882:1998 -- International Standard for Information Systems -- Programming Language C++, Section 24.3.4



Previous fileTop of DocumentContentsIndex pageNext file

Copyright (c) 1994-2006 Rogue Wave Software, a Quovadx Division.
Licensed under the Apache License, Version 2.0.
Contact Rogue Wave about documentation or support issues. You can also seek help from other developers through the Apache stdcxx community (see below).

For more information on the Rogue Wave Standard C++ Library under open source, see Section 1.2 of the user's guide.