2 [section:concepts Iterator Concepts]
4 [section:concepts_access Access]
6 [h2 Readable Iterator Concept]
8 A class or built-in type `X` models the *Readable Iterator* concept
9 for value type `T` if, in addition to `X` being Assignable and
10 Copy Constructible, the following expressions are valid and respect
11 the stated semantics. `U` is the type of any specified member of
14 [table Readable Iterator Requirements (in addition to Assignable and Copy Constructible)
21 [`iterator_traits<X>::value_type`]
23 [Any non-reference, non cv-qualified type]
28 [pre: `a` is dereferenceable. If `a == b` then `*a` is equivalent to `*b`.]
33 [pre: `(*a).m` is well-defined. Equivalent to `(*a).m`.]
37 [h2 Writable Iterator Concept ]
40 A class or built-in type `X` models the *Writable Iterator* concept
41 if, in addition to `X` being Copy Constructible, the following
42 expressions are valid and respect the stated semantics. Writable
43 Iterators have an associated *set of value types*.
45 [table Writable Iterator Requirements (in addition to Copy Constructible)
54 [pre: The type of `o` is in the set of value types of `X`]
58 [h2 Swappable Iterator Concept]
60 A class or built-in type `X` models the *Swappable Iterator* concept
61 if, in addition to `X` being Copy Constructible, the following
62 expressions are valid and respect the stated semantics.
64 [table Swappable Iterator Requirements (in addition to Copy Constructible)
73 [the pointed to values are exchanged]
77 [blurb *Note:* An iterator that is a model of the *Readable* and *Writable Iterator* concepts
78 is also a model of *Swappable Iterator*. *--end note*]
80 [h2 Lvalue Iterator Concept]
82 The *Lvalue Iterator* concept adds the requirement that the return
83 type of `operator*` type be a reference to the value type of the
86 [table Lvalue Iterator Requirements
96 `T` is *cv* `iterator_traits<X>::value_type` where *cv* is an optional cv-qualification.
97 pre: `a` is dereferenceable. If `a == b` then `*a` is equivalent to `*b`.
104 [section:concepts_traversal Traversal]
106 [h2 Incrementable Iterator Concept]
109 A class or built-in type `X` models the *Incrementable Iterator*
110 concept if, in addition to `X` being Assignable and Copy
111 Constructible, the following expressions are valid and respect the
115 [table Incrementable Iterator Requirements (in addition to Assignable, Copy Constructible)
119 [Assertion/Semantics ]
138 [`iterator_traversal<X>::type`]
139 [Convertible to `incrementable_traversal_tag`]
144 [h2 Single Pass Iterator Concept]
146 A class or built-in type `X` models the *Single Pass Iterator*
147 concept if the following expressions are valid and respect the stated
150 [table Single Pass Iterator Requirements (in addition to Incrementable Iterator and Equality Comparable)
154 [Assertion/Semantics / Pre-/Post-condition]
159 [pre:[br]`r` is dereferenceable;[br]post:[br]`r` is dereferenceable or[br]`r` is past-the-end]
163 [convertible to `bool`]
164 [`==` is an equivalence relation over its domain]
168 [convertible to `bool`]
172 [`iterator_traversal<X>::type`]
173 [Convertible to`single_pass_traversal_tag`]
179 [h2 Forward Traversal Concept]
181 A class or built-in type `X` models the *Forward Traversal*
182 concept if, in addition to `X` meeting the requirements of Default
183 Constructible and Single Pass Iterator, the following expressions are
184 valid and respect the stated semantics.
186 [table Forward Traversal Iterator Requirements (in addition to Default Constructible and Single Pass Iterator)
195 [note: `u` may have a singular value.]
200 [`r == s` and `r` is dereferenceable implies `++r == ++s.`]
203 [`iterator_traits<X>::difference_type`]
204 [A signed integral type representing the distance between iterators]
208 [`iterator_traversal<X>::type`]
209 [Convertible to `forward_traversal_tag`]
214 [h2 Bidirectional Traversal Concept]
216 A class or built-in type `X` models the *Bidirectional Traversal*
217 concept if, in addition to `X` meeting the requirements of Forward
218 Traversal Iterator, the following expressions are valid and respect
219 the stated semantics.
221 [table Bidirectional Traversal Iterator Requirements (in addition to Forward Traversal Iterator)
225 [Assertion/Semantics/Pre-/Post-condition]
230 [pre: there exists `s` such that `r == ++s`.[br] post: `s` is dereferenceable. `--(++r) == r`. `--r == --s` implies `r == s`. `&r == &--r`.]
234 [convertible to `const X&`]
244 [`iterator_traversal<X>::type`]
245 [Convertible to `bidirectional_traversal_tag`]
250 [h2 Random Access Traversal Concept]
252 A class or built-in type `X` models the *Random Access Traversal*
253 concept if the following expressions are valid and respect the stated
254 semantics. In the table below, `Distance` is
255 `iterator_traits<X>::difference_type` and `n` represents a
256 constant object of type `Distance`.
258 [table Random Access Traversal Iterator Requirements (in addition to Bidirectional Traversal)
262 [Operational Semantics]
263 [Assertion/Precondition]
313 [`a < b ? distance(a,b) : -distance(b,a)`]
314 [pre: there exists a value `n` of `Distance` such that `a + n == b`. `b == a + (b - a)`.]
320 [pre: a is a *Readable Iterator*]
326 [pre: a is a *Writable iterator*]
330 [convertible to `bool`]
332 [`<` is a total ordering relation]
336 [convertible to `bool`]
338 [`>` is a total ordering relation]
342 [convertible to `bool`]
348 [convertible to `bool`]
353 [`iterator_traversal<X>::type`]
354 [convertible to `random_access_traversal_tag`]