[iterator.concept.random.access] (original) (raw)
23 Iterators library [iterators]
23.3 Iterator requirements [iterator.requirements]
23.3.4 Iterator concepts [iterator.concepts]
23.3.4.13 Concept random_access_iterator [iterator.concept.random.access]
The random_access_iterator concept adds support for constant-time advancement with +=, +, -=, and -, as well as the computation of distance in constant time with -.
Random access iterators also support array notation via subscripting.
Let a and b be valid iterators of type Isuch that b is reachable from aafter n applications of ++a, let D be iter_difference_t<I>, and let n denote a value of type D.
I models random_access_iterator only if
- addressof(a += n) is equal to addressof(a).
- (a + n) is equal to (a += n).
- For any two positive valuesx and y of type D, if (a + D(x + y)) is valid, then(a + D(x + y)) is equal to ((a + x) + y).
- (a + D(0)) is equal to a.
- If (a + D(n - 1)) is valid, then(a + n) is equal to [](I c){ return ++c; }(a + D(n - 1)).
- (b += D(-n)) is equal to a.
- addressof(b -= n) is equal to addressof(b).
- (b - n) is equal to (b -= n).
- If b is dereferenceable, thena[n] is valid and is equal to *b.