[tab:randomaccessiterator] (original) (raw)

Table 89: Cpp17RandomAccessIterator requirements (in addition to Cpp17BidirectionalIterator) [tab:randomaccessiterator]

🔗 Expression Return type Operational Assertion/note
🔗 semantics pre-/post-condition
🔗 r += n X& { difference_­type m = n; if (m >= 0) while (m--) ++r; else while (m++) --r; return r; }
🔗 a + nn + a X { X tmp = a; return tmp += n; } a + n == n + a.
🔗 r -= n X& return r += -n; Preconditions: the absolute value of n is in the range of representable values of difference_­type.
🔗 a - n X { X tmp = a; return tmp -= n; }
🔗 b - a difference_­type return n Preconditions: there exists a value n of type difference_­type such that a + n == b. b == a + (b - a).
🔗 a[n] convertible to reference *(a + n)
🔗 a < b contextually convertible to bool b - a > 0 < is a total ordering relation
🔗 a > b contextually convertible to bool b < a > is a total ordering relation opposite to <.
🔗 a >= b contextually convertible to bool !(a < b)
🔗 a <= b contextually convertible to bool. !(a > b)