A Random Access Iterator is a <ahref="./Bidirectional_Iterator.html">Bidirectional Iterator</a> that provides constant-time methods for moving forward and backward on a sequence in arbitrary-sized steps.
Random Access Iterator defines two new expressions and refines the ones described in <ahref="./Bidirectional_Iterator.html">Bidirectional Iterator</a>.
<p>
<tableborder="1">
<tr><th> Expression </th><th> Expression type </th></tr>
<tr><td><code>typename i::next</code></td><td>A model of <ahref="./Random_Access_Iterator.html">Random Access Iterator</a></td></tr>
<tr><td><code>typename i::prior</code></td><td>A model of <ahref="./Random_Access_Iterator.html">Random Access Iterator</a></td></tr>
<tr><td><code>typename i::template advance<n>::type</code></td><td>A model of <ahref="./Random_Access_Iterator.html">Random Access Iterator</a></td></tr>
<tr><td><code>typename i::template distance<j>::type</code></td><td>A model of <ahref="./Integral_Constant.html">Integral Constant</a></td></tr>
</table>
<p>
<h3>Expression semantics</h3>
<p>
Semantics of an expression is defined only where it is not defined in <ahref="./Bidirectional_Iterator.html">Bidirectional Iterator</a>.
<tr><td><code>typename i::template advance<n>::type</code></td><td>Amortized constant time</td><td>Including <code>i</code> itself, there must be <code>n::value</code> dereferenceable or past-the-end iterators following or preceding <code>i</code>, depending on whether <code>n</code> is positive or negative.</td><td>If <code>n::value > 0</code>, equivalent to executing <code>i::next</code><code>n::value</code> times; if <code>n::value < 0</code>, equivalent to executing <code>i::prior</code><code>n::value</code> times; if <code>n::value == 0</code>, this is a null operation [<ahref="#1">1</a>].</td><td>The resulting iterator is dereferenceable or past-the-end. </td></tr>
<tr><td><code>typename i::template distance<j>::type</code></td><td>Amortized constant time</td><td>Either <code>i</code> is reachable from <code>j</code> or <code>j</code> is reachable from <code>i</code>, or both.</td><td>Returns an integral constant <code>n</code> such that <code>i::template advance<n>::type</code> is identical to <code>j</code>. </td></tr>
</table>
<p>
<h3>Invariants</h3>
<p>
For any random access iterators <code>i</code> and <code>j</code> the following invariants always hold:
<p>
<ul>
<li>if <code>i::advance<n>::type</code> is well-defined, then <code>i::advance<n>::type::advance<<ahref="./Reference/negate.html">negate</a><n>::type >::type</code> is a null operation.