Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is an old version of boost. Click here for the latest version's documentation home page.
Concept ForwardIterator
c++boost.gif (8819 bytes)HomeLibrariesPeopleFAQMore

Concept ForwardIterator

ForwardIterator

Description

A forward iterator is an iterator that can read through a sequence of values. It is multi-pass (old values of the iterator can be re-used), and can be either mutable (data pointed to by it can be changed) or not mutable.

An iterator represents a position in a sequence. Therefore, the iterator can point into the sequence (returning a value when dereferenced and being incrementable), or be off-the-end (and not dereferenceable or incrementable).

Refinement of

Associated types

  • value_type

    std::iterator_traits<Iter>::value_type

    The value type of the iterator

  • category

    std::iterator_traits<Iter>::iterator_category

    The category of the iterator

Notation

Iter
A type playing the role of iterator-type in the ForwardIterator concept.
i, j
Objects of type Iter
x
Object of type value_type

Type expressions

Category tag

category must be derived from std::forward_iterator_tag.

Valid expressions

NameExpressionTypePreconditionSemanticsPostcondition

Dereference

*i

const-if-not-mutable value_type &

i is incrementable (not off-the-end)

  

Member access

i->{member-name} (return type is pointer-to-object type)

const-if-not-mutable value_type *

i is incrementable (not off-the-end)

  

Preincrement

++i

Iter &

i is incrementable (not off-the-end)

  

Postincrement

i++

Iter

i is incrementable (not off-the-end)

Equivalent to {Iter j = i; ++i; return j;}

i is dereferenceable or off-the-end

Complexity

All iterator operations must take amortized constant time.

Invariants

Predecrement must return object

&i = &(++i)

Unique path through sequence

i == j implies ++i == ++j

Models

  • T *
  • std::hash_set<T>::iterator

See also

Last revised: , at GMTCopyright © 2001, 2002 Indiana University
Copyright © 2000, 2001 University of Notre Dame du Lac
Copyright © 2000 Jeremy Siek, Lie-Quan Lee, Andrew Lumsdaine
Copyright © 1996-1999 Silicon Graphics Computer Systems, Inc.
Copyright © 1994 Hewlett-Packard Company