[random.access.iterators]
# 24 Iterators library [[iterators]](./#iterators)
## 24.3 Iterator requirements [[iterator.requirements]](iterator.requirements#random.access.iterators)
### 24.3.5 C++17 iterator requirements [[iterator.cpp17]](iterator.cpp17#random.access.iterators)
#### 24.3.5.7 Random access iterators [random.access.iterators]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L2349)
A class or pointer typeX meets the requirements of a random access iterator if,
in addition to meeting the *Cpp17BidirectionalIterator* requirements,
the following expressions are valid as shown in Table [83](#tab:randomaccessiterator "Table 83: Cpp17RandomAccessIterator requirements (in addition to Cpp17BidirectionalIterator)")[.](#1.sentence-1)
Table [83](#tab:randomaccessiterator) — *Cpp17RandomAccessIterator* requirements (in addition to *Cpp17BidirectionalIterator*) [[tab:randomaccessiterator]](./tab:randomaccessiterator)
| [ð](#tab:randomaccessiterator-row-1)
**Expression** | **Return type** | **Operational** | **Assertion/note** |
| --- | --- | --- | --- |
| [ð](#tab:randomaccessiterator-row-2) | | **semantics** | **pre-/post-condition** |
| [ð](#tab:randomaccessiterator-row-3)
r += n | X& | { difference_type m = n; if (m >= 0) while (m--) ++r; else while (m++) --r; return r; } | |
| [ð](#tab:randomaccessiterator-row-4)
a + n n + a | X | { X tmp = a; return tmp += n; } | a + n == n + a[.](#tab:randomaccessiterator-row-4-column-4-sentence-1) |
| [ð](#tab:randomaccessiterator-row-5)
r -= n | X& | return r += -n; | *Preconditions*: the absolute value of n is in the range of representable values of difference_type[.](#tab:randomaccessiterator-row-5-column-4-sentence-1) |
| [ð](#tab:randomaccessiterator-row-6)
a - n | X | { X tmp = a; return tmp -= n; } | |
| [ð](#tab:randomaccessiterator-row-7)
b - a | difference_type | return n; | *Preconditions*: there exists a value n of type difference_type such that a + n == b[.](#tab:randomaccessiterator-row-7-column-4-sentence-1)
b == a + (b - a)[.](#tab:randomaccessiterator-row-7-column-4-sentence-2) |
| [ð](#tab:randomaccessiterator-row-8)
a[n] | convertible to reference | *(a + n) | |
| [ð](#tab:randomaccessiterator-row-9)
a < b | decltype(a < b) models *boolean-testable* | *Effects*: Equivalent to: return b - a > 0; | < is a total ordering relation |
| [ð](#tab:randomaccessiterator-row-10)
a > b | decltype(a > b) models *boolean-testable* | b < a | > is a total ordering relation opposite to <[.](#tab:randomaccessiterator-row-10-column-4-sentence-1) |
| [ð](#tab:randomaccessiterator-row-11)
a >= b | decltype(a >= b) models *boolean-testable* | !(a < b) | |
| [ð](#tab:randomaccessiterator-row-12)
a <= b | decltype(a <= b) models *boolean-testable* | !(a > b) | |