...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
A class or built-in type X
models the Incrementable Iterator concept
if, in addition to X
being
Assignable and Copy Constructible, the following expressions are valid
and respect the stated semantics.
Table 1.5. Incrementable Iterator Requirements (in addition to Assignable, Copy Constructible)
Expression |
Return Type |
Assertion/Semantics |
---|---|---|
|
|
|
|
|
{ X tmp = r; ++r; return tmp; } |
|
Convertible to |
A class or built-in type X
models the Single Pass Iterator concept
if the following expressions are valid and respect the stated semantics.
Table 1.6. Single Pass Iterator Requirements (in addition to Incrementable Iterator and Equality Comparable)
Expression |
Return Type |
Assertion/Semantics / Pre-/Post-condition |
---|---|---|
|
|
pre: |
|
convertible to |
|
|
convertible to |
|
|
A signed integral type representing the distance between iterators |
|
|
Convertible to |
A class or built-in type X
models the Forward Traversal concept if,
in addition to X
meeting
the requirements of Default Constructible and Single Pass Iterator, the
following expressions are valid and respect the stated semantics.
Table 1.7. Forward Traversal Iterator Requirements (in addition to Default Constructible and Single Pass Iterator)
Expression |
Return Type |
Assertion/Note |
---|---|---|
|
|
note: |
|
|
|
|
Convertible to |
A class or built-in type X
models the Bidirectional Traversal concept
if, in addition to X
meeting
the requirements of Forward Traversal Iterator, the following expressions
are valid and respect the stated semantics.
Table 1.8. Bidirectional Traversal Iterator Requirements (in addition to Forward Traversal Iterator)
Expression |
Return Type |
Assertion/Semantics/Pre-/Post-condition |
---|---|---|
|
|
pre: there exists |
|
convertible to |
{ X tmp = r; --r; return tmp; } |
|
Convertible to |
A class or built-in type X
models the Random Access Traversal concept
if the following expressions are valid and respect the stated semantics.
In the table below, Distance
is iterator_traits<X>::difference_type
and n
represents a constant object of type Distance
.
Table 1.9. Random Access Traversal Iterator Requirements (in addition to Bidirectional Traversal)
Expression |
Return Type |
Operational Semantics |
Assertion/Precondition |
---|---|---|---|
|
|
{ Distance m = n; if (m >= 0) while (m--) ++r; else while (m++) --r; return r; } |
|
|
|
{ X tmp = a; return tmp+= n; } |
|
|
|
|
|
|
|
{ X tmp = a; return tmp-= n; } |
|
|
|
|
pre: there exists a value |
|
convertible to T |
|
pre: a is a Readable Iterator |
|
convertible to T |
|
pre: a is a Writable iterator |
|
convertible to |
|
|
|
convertible to |
|
|
|
convertible to |
|
|
|
convertible to |
|
|
|
convertible to |