52 lines
2.4 KiB
Markdown
52 lines
2.4 KiB
Markdown
[iterator.iterators]
|
||
|
||
# 24 Iterators library [[iterators]](./#iterators)
|
||
|
||
## 24.3 Iterator requirements [[iterator.requirements]](iterator.requirements#iterator.iterators)
|
||
|
||
### 24.3.5 C++17 iterator requirements [[iterator.cpp17]](iterator.cpp17#iterator.iterators)
|
||
|
||
#### 24.3.5.2 *Cpp17Iterator* [iterator.iterators]
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L2025)
|
||
|
||
The *Cpp17Iterator* requirements form the basis of the iterator
|
||
taxonomy; every iterator meets the *Cpp17Iterator* requirements[.](#1.sentence-1)
|
||
|
||
This
|
||
set of requirements specifies operations for dereferencing and incrementing
|
||
an iterator[.](#1.sentence-2)
|
||
|
||
Most algorithms will require additional operations to
|
||
read ([[input.iterators]](input.iterators "24.3.5.3 Input iterators")) or write ([[output.iterators]](output.iterators "24.3.5.4 Output iterators")) values, or
|
||
to provide a richer set of iterator movements ([[forward.iterators]](forward.iterators "24.3.5.5 Forward iterators"), [[bidirectional.iterators]](bidirectional.iterators "24.3.5.6 Bidirectional iterators"), [[random.access.iterators]](random.access.iterators "24.3.5.7 Random access iterators"))[.](#1.sentence-3)
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L2034)
|
||
|
||
A type X meets the *Cpp17Iterator* requirements if
|
||
|
||
- [(2.1)](#2.1)
|
||
|
||
X meets the *Cpp17CopyConstructible*, *Cpp17CopyAssignable*, *Cpp17Swappable*, and*Cpp17Destructible* requirements ([[utility.arg.requirements]](utility.arg.requirements "16.4.4.2 Template argument requirements"), [[swappable.requirements]](swappable.requirements "16.4.4.3 Swappable requirements")), and
|
||
|
||
- [(2.2)](#2.2)
|
||
|
||
iterator_traits<X>::difference_type is a signed integer type or void, and
|
||
|
||
- [(2.3)](#2.3)
|
||
|
||
the expressions in Table [78](#tab:iterator "Table 78: Cpp17Iterator requirements") are valid and have
|
||
the indicated semantics[.](#2.sentence-1)
|
||
|
||
Table [78](#tab:iterator) — *Cpp17Iterator* requirements [[tab:iterator]](./tab:iterator)
|
||
|
||
| [ð](#tab:iterator-row-1)<br>**Expression** | **Return type** | **Operational** | **Assertion/note** |
|
||
| --- | --- | --- | --- |
|
||
| [ð](#tab:iterator-row-2) | | **semantics** | **pre-/post-condition** |
|
||
| [ð](#tab:iterator-row-3)<br>*r | unspecified | | *Preconditions*: r is dereferenceable[.](#tab:iterator-row-3-column-4-sentence-1) |
|
||
| [ð](#tab:iterator-row-4)<br>++r | X& | | |
|