Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Iterator Concepts

Access
Traversal

Readable Iterator Concept

A class or built-in type X models the Readable Iterator concept for value type T if, in addition to X being Assignable and Copy Constructible, the following expressions are valid and respect the stated semantics. U is the type of any specified member of type T.

Table 1.1. Readable Iterator Requirements (in addition to Assignable and Copy Constructible)

Expression

Return Type

Note/Precondition

iterator_traits<X>::value_type

T

Any non-reference, non cv-qualified type

*a

Convertible to T

pre: a is dereferenceable. If a == b then *a is equivalent to *b.

a->m

U&

pre: (*a).m is well-defined. Equivalent to (*a).m.


Writable Iterator Concept

A class or built-in type X models the Writable Iterator concept if, in addition to X being Copy Constructible, the following expressions are valid and respect the stated semantics. Writable Iterators have an associated set of value types.

Table 1.2. Writable Iterator Requirements (in addition to Copy Constructible)

Expression

Return Type

Precondition

*a = o

pre: The type of o is in the set of value types of X


Swappable Iterator Concept

A class or built-in type X models the Swappable Iterator concept if, in addition to X being Copy Constructible, the following expressions are valid and respect the stated semantics.

Table 1.3. Swappable Iterator Requirements (in addition to Copy Constructible)

Expression

Return Type

Postcondition

iter_swap(a, b)

void

the pointed to values are exchanged


Lvalue Iterator Concept

The Lvalue Iterator concept adds the requirement that the return type of operator* type be a reference to the value type of the iterator.

Table 1.4. Lvalue Iterator Requirements

Expression

Return Type

Note/Assertion

*a

T&

T is cv iterator_traits<X>::value_type where cv is an optional cv-qualification. pre: a is dereferenceable. If a == b then *a is equivalent to *b.



PrevUpHomeNext