The Wayback Machine - https://web.archive.org/web/20120521112801/http://en.cppreference.com:80/w/cpp/iterator

Iterator library

From cppreference.com
< cpp
Jump to: navigation, search

Iterators are a generalization of pointers that allow C++ programs to access different containers in a uniform manner. Any algorithm that accepts iterators should accept regular pointers also.

Contents

[edit] Iterator Types

Five iterator categories are defined, according to operations defined on them:

allows reading from the iterator object
allows iterating forward without multi-pass guarantee, i. e. reading the same element twice is not guaranteed to produce the same results
allows writing to the iterator object
allows iterating forward without multi-pass guarantee
allows reading from the iterator object
allows iterating forward with multi-pass guarantee, i. e. reading the same element twice is guaranteed to produce the same results
allows reading from the iterator object
allows iterating forward and backward with multi-pass guarantee
allows reading from the iterator object
allows iterating forward and backward randomly with multi-pass guarantee

Forward iterators satisfy the requirements of input iterators

[edit] Iterator primitives

provides uniform interface to the properties of an iterator
(class template) [edit]
empty class types used to indicate iterator categories
(class) [edit]
the basic iterator
(class template) [edit]

[edit] Iterator adaptors

iterator adaptor for reverse-order traversal
(class template) [edit]
iterator adaptor which dereferences to an rvalue reference
(class template) [edit]
creates a std::move_iterator of type inferred from the argument
(function template) [edit]
iterator adaptor for insertion at the end of a container
(class template) [edit]
creates a std::back_insert_iterator of type inferred from the argument
(function template) [edit]
iterator adaptor for insertion at the front of a container
(class template) [edit]
creates a std::front_insert_iterator of type inferred from the argument
(function template) [edit]
iterator adaptor for insertion into a container
(class template) [edit]
creates a std::insert_iterator of type inferred from the argument
(function template) [edit]

[edit] Stream iterators

input iterator that reads from std::basic_istream
(class template) [edit]
output iterator that writes to std::basic_ostream
(class template) [edit]
input iterator that reads from std::basic_streambuf
(class template) [edit]
output iterator that writes to std::basic_streambuf
(class template) [edit]

[edit] Iterator Operations

Defined in header <iterator>
advances an iterator by given distance
(function) [edit]
returns the distance between two iterators
(function) [edit]
(C++11)
increment an iterator
(function) [edit]
(C++11)
decrement an iterator
(function) [edit]

[edit] Range Access

Defined in header <iterator>
(C++11)
returns an iterator to the beginning of a container or array
(function) [edit]
(C++11)
returns an iterator to the end of a container or array
(function) [edit]

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox
In other languages