[iterator.concept.random.access]

# 24 Iterators library [[iterators]](./#iterators)

## 24.3 Iterator requirements [[iterator.requirements]](iterator.requirements#iterator.concept.random.access)

### 24.3.4 Iterator concepts [[iterator.concepts]](iterator.concepts#iterator.concept.random.access)

#### 24.3.4.13 Concept random_access_iterator [iterator.concept.random.access]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L1902)

The [random_access_iterator](#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]") concept adds support for
constant-time advancement with +=, +, -=, and -,
as well as the computation of distance in constant time with -[.](#1.sentence-1)

Random access iterators also support array notation via subscripting[.](#1.sentence-2)

template<class I>concept [random_access_iterator](#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]") =[bidirectional_iterator](iterator.concept.bidir#concept:bidirectional_iterator "24.3.4.12 Concept bidirectional_­iterator [iterator.concept.bidir]")<I> &&[derived_from](concept.derived#concept:derived_from "18.4.3 Concept derived_­from [concept.derived]")<*ITER_CONCEPT*(I), random_access_iterator_tag> &&[totally_ordered](concept.totallyordered#concept:totally_ordered "18.5.5 Concept totally_­ordered [concept.totallyordered]")<I> &&[sized_sentinel_for](iterator.concept.sizedsentinel#concept:sized_sentinel_for "24.3.4.8 Concept sized_­sentinel_­for [iterator.concept.sizedsentinel]")<I, I> &&requires(I i, const I j, const iter_difference_t<I> n) {{ i += n } -> [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<I&>; { j + n } -> [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<I>; { n + j } -> [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<I>; { i -= n } -> [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<I&>; { j - n } -> [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<I>; { j[n] } -> [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<iter_reference_t<I>>; };

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L1925)

Let a and b be valid iterators of type I such that b is reachable from a after n applications of ++a,
let D be iter_difference_t<I>,
and let n denote a value of type D[.](#2.sentence-1)

I models [random_access_iterator](#concept:random_access_iterator "24.3.4.13 Concept random_­access_­iterator [iterator.concept.random.access]") only if:

- [(2.1)](#2.1)

  (a += n) is equal to b[.](#2.1.sentence-1)

- [(2.2)](#2.2)

  addressof(a += n) is equal to addressof(a)[.](#2.2.sentence-1)

- [(2.3)](#2.3)

  (a + n) is equal to (a += n)[.](#2.3.sentence-1)

- [(2.4)](#2.4)

  For any two positive values x and y of type D,
 if (a + D(x + y)) is valid, then (a + D(x + y)) is equal to ((a + x) + y)[.](#2.4.sentence-1)

- [(2.5)](#2.5)

  (a + D(0)) is equal to a[.](#2.5.sentence-1)

- [(2.6)](#2.6)

  If (a + D(n - 1)) is valid, then (a + n) is equal to [](I c){ return ++c; }(a + D(n - 1))[.](#2.6.sentence-1)

- [(2.7)](#2.7)

  (b += D(-n)) is equal to a[.](#2.7.sentence-1)

- [(2.8)](#2.8)

  (b -= n) is equal to a[.](#2.8.sentence-1)

- [(2.9)](#2.9)

  addressof(b -= n) is equal to addressof(b)[.](#2.9.sentence-1)

- [(2.10)](#2.10)

  (b - n) is equal to (b -= n)[.](#2.10.sentence-1)

- [(2.11)](#2.11)

  If b is dereferenceable, then a[n] is valid and is equal to *b[.](#2.11.sentence-1)

- [(2.12)](#2.12)

  bool(a <= b) is true[.](#2.12.sentence-1)
