[#BloombergLP-bslstl-RandomAccessIterator]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslstl.adoc[bslstl]::RandomAccessIterator
:relfileprefix: ../../
:mrdocs:

Given an `ITER&lowbar;IMP` type that implements a minimal subset of an iterator interface, this template generates a complete iterator that meets all of the requirements of a &quot;random&hyphen;access iterator&quot; in the C&plus;&plus; standard&period; If `T` is const&hyphen;qualified, then the resulting type is a const iterator&period; `T` shall not be a function, reference type or void&period; `ITER&lowbar;IMP` must provide public operations so that, for objects `i` and `j` of type `ITER&lowbar;IMP` and `n` of an integral type, the following operations are supported&colon; &grave; ITER&lowbar;IMP i&semi; default construction ITER&lowbar;IMP j(i)&semi; copy construction i &equals; j assignment &plus;&plus;i increment to next element &hyphen;&hyphen;i decrement to previous element i &plus;&equals; n increment by n elements i &hyphen;&equals; n decrement by n elements j &hyphen; i &sol;&sol; convertible to ptrdiff&lowbar;t distance from i to j i &equals;&equals; j &sol;&sol; convertible to bool equality comparison i &lt; j &sol;&sol; convertible to bool less&hyphen;than comparison &ast;i &sol;&sol; reference convertible to T&amp; element access (dereference) &grave;

== Synopsis

Declared in `&lt;bslstl&lowbar;randomaccessiterator&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class T,
    class ITER&lowbar;IMP,
    class TAG&lowbar;TYPE = std::random&lowbar;access&lowbar;iterator&lowbar;tag&gt;
class RandomAccessIterator
    : public xref:BloombergLP/bslstl/BidirectionalIterator.adoc[BidirectionalIterator&lt;T, ITER&lowbar;IMP, TAG&lowbar;TYPE&gt;]
----

== Base Classes

[cols="1,4"]
|===
| Name| Description
| `xref:BloombergLP/bslstl/BidirectionalIterator.adoc[BidirectionalIterator&lt;T, ITER&lowbar;IMP, TAG&lowbar;TYPE&gt;]`
| Given an `ITER&lowbar;IMP` type that implements a minimal subset of an iterator interface, this template generates a complete iterator that meets all of the requirements of a &quot;bidirectional iterator&quot; in the C&plus;&plus; standard&period; If `T` is `const`&hyphen;qualified, then the resulting type is a constant iterator&period; `T` shall not be a function, reference type or void&period; `ITER&lowbar;IMP` must provide public operations so that, for objects `i` and `j` of type `ITER&lowbar;IMP`, the following operations are supported&colon; &grave; ITER&lowbar;IMP i&semi; default construction ITER&lowbar;IMP j(i)&semi; copy construction i &equals; j assignment &plus;&plus;i increment to next element &hyphen;&hyphen;i decrement to previous element i &equals;&equals; j &sol;&sol; convertible to bool equality comparison &ast;i &sol;&sol; reference convertible to T&amp; element access (dereference) &grave;
|===

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslstl/RandomAccessIterator/difference_type.adoc[`difference&lowbar;type`] 
| Signed integer type measuring iterator distance&period;
| xref:BloombergLP/bslstl/RandomAccessIterator/iterator_category.adoc[`iterator&lowbar;category`] 
| Random&hyphen;access iterator category tag&period;
| xref:BloombergLP/bslstl/RandomAccessIterator/pointer.adoc[`pointer`] 
| Pointer type for the iterator&apos;s value type&period;
| xref:BloombergLP/bslstl/RandomAccessIterator/reference.adoc[`reference`] 
| Reference type for the iterator&apos;s value type&period;
| xref:BloombergLP/bslstl/RandomAccessIterator/value_type.adoc[`value&lowbar;type`] 
| Value type referred to by this iterator&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslstl/RandomAccessIterator/2constructor-0be.adoc[`RandomAccessIterator`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/bslstl/RandomAccessIterator/operator_assign-04.adoc[`operator&equals;`] 
| Assignment operators
| xref:BloombergLP/bslstl/ForwardIterator/imp-0e.adoc[`imp`] 
| `imp` overloads
| xref:BloombergLP/bslstl/ForwardIterator/operator_star.adoc[`operator&ast;`] 
| Return a reference to the current, modifiable element&period; The behavior is undefined if this iterator has the past&hyphen;the&hyphen;end value for an iterator over the underlying sequence&period;
| xref:BloombergLP/bslstl/RandomAccessIterator/operator_inc.adoc[`operator&plus;&plus;`] 
| Increment to the next element&period; Return a reference to this modifiable iterator&period; The behavior is undefined if, on entry, this iterator has the past&hyphen;the&hyphen;end value for an iterator over the underlying sequence&period;
| xref:BloombergLP/bslstl/RandomAccessIterator/operator_plus_eq.adoc[`operator&plus;&equals;`] 
| Increment by the specified `offset` number of elements&period; Return a reference to this modifiable iterator&period; The behavior is undefined unless the iterator, after incrementing by `offset`, is within the bounds of the underlying sequence&period;
| xref:BloombergLP/bslstl/RandomAccessIterator/operator_dec.adoc[`operator&hyphen;&hyphen;`] 
| Decrement to the previous element&period; Return a reference to this modifiable iterator&period; The behavior is undefined if, on entry, this iterator has the same value as an iterator to the start of the underlying sequence&period;
| xref:BloombergLP/bslstl/RandomAccessIterator/operator_minus_eq.adoc[`operator&hyphen;&equals;`] 
| Decrement by the specified `offset` number of elements&period; Return a reference to this modifiable iterator&period; The behavior is undefined unless the iterator, after decrementing by `offset`, is within the bounds of the underlying sequence&period;
| xref:BloombergLP/bslstl/ForwardIterator/operator_ptr.adoc[`operator&hyphen;&gt;`] 
| Return a pointer to the current, modifiable element&period; The behavior is undefined if this iterator has the past&hyphen;the&hyphen;end value for an iterator over the underlying sequence&period;
| xref:BloombergLP/bslstl/RandomAccessIterator/operator_subs.adoc[`operator&lsqb;&rsqb;`] 
| Return a reference to the element at the specified `index` positions past the current one&period; The behavior is undefined unless the referenced position lies within the underlying sequence&period; Note that `index` may be negative&period;
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslstl/operator_not_eq-093.adoc[`operator!&equals;`]
| Return `true` if the specified `lhs` iterator does not have the same value as the specified `rhs` iterator, and `false` otherwise&period; Two iterators do not have the same value if (1) they do not refer to the same element and (2) both do not have the past&hyphen;the&hyphen;end iterator value for the underlying sequence&period; The behavior is undefined unless both iterators refer to the same underlying sequence&period;
| xref:BloombergLP/bslstl/operator_not_eq-0bc.adoc[`operator!&equals;`]
| Return `true` if the specified `lhs` iterator does not have the same value as the specified `rhs` iterator, and `false` otherwise&period; Two iterators do not have the same value if (1) they do not refer to the same element and (2) both do not have the past&hyphen;the&hyphen;end iterator value for the underlying sequence&period; The behavior is undefined unless both iterators refer to the same underlying sequence&period;
| xref:BloombergLP/bslstl/operator_not_eq-0d.adoc[`operator!&equals;`]
| Return `true` if the specified `lhs` iterator does not have the same value as the specified `rhs` iterator, and `false` otherwise&period; Two iterators do not have the same value if (1) they do not refer to the same element and (2) both do not have the past&hyphen;the&hyphen;end iterator value for the underlying sequence&period; The behavior is undefined unless both iterators refer to the same underlying sequence&period;
| xref:BloombergLP/bslstl/operator_plus-09.adoc[`operator&plus;`]
| Return an iterator to the element at the specified `rhs` positions past the specified `lhs`&period; The behavior is undefined unless `lhs`, after incrementing by `rhs`, is within the bounds of the underlying sequence&period;
| xref:BloombergLP/bslstl/operator_plus-0fa.adoc[`operator&plus;`]
| Return an iterator to the element at the specified `lhs` positions past the specified `rhs`&period; The behavior is undefined unless `rhs`, after incrementing by `lhs`, is within the bounds of the underlying sequence&period;
| xref:BloombergLP/bslstl/operator_inc-005.adoc[`operator&plus;&plus;`]
| Increment the specified `iter` to next element&period; Return the previous value of `iter`&period; The behavior is undefined if, on entry, `iter` has the past&hyphen;the&hyphen;end value for an iterator of the underlying sequence&period;
| xref:BloombergLP/bslstl/operator_inc-008.adoc[`operator&plus;&plus;`]
| Increment the specified `iter` to the next element&period; Return the previous value of `iter`&period; The behavior is undefined if, on entry, `iter` has the past&hyphen;the&hyphen;end value for an iterator of the underlying sequence&period;
| xref:BloombergLP/bslstl/operator_inc-07.adoc[`operator&plus;&plus;`]
| Increment the specified `iter` to the next element&period; Return the previous value of `iter`&period; The behavior is undefined if, on entry, `iter` has the past&hyphen;the&hyphen;end value for an iterator of the underlying sequence&period;
| xref:BloombergLP/bslstl/operator_minus-02.adoc[`operator&hyphen;`]
| Return an iterator to the element at the specified `rhs` positions before the specified `lhs`&period; The behavior is undefined unless `lhs`, after decrementing by `rhs`, is within the bounds of the underlying sequence&period; Note that this function is logically equivalent to&colon; &grave; iter &plus; (&hyphen;rhs) &grave;
| xref:BloombergLP/bslstl/operator_minus-0b.adoc[`operator&hyphen;`]
| Return the distance from the specified `rhs` iterator to the specified `lhs` iterator&period; The behavior is undefined unless `lhs` and `rhs` are iterators into the same underlying sequence&period; Note that the result might be negative&period;
| xref:BloombergLP/bslstl/operator_dec-05.adoc[`operator&hyphen;&hyphen;`]
| Decrement the specified `iter` to previous element&period; Return the previous value of `iter`&period; The behavior is undefined if, on entry, `iter` has the same value as an iterator to the start of the underlying sequence&period;
| xref:BloombergLP/bslstl/operator_dec-08.adoc[`operator&hyphen;&hyphen;`]
| Decrement the specified `iter` to the previous element&period; Return the previous value of `iter`&period; The behavior is undefined if, on entry, `iter` has the same value as an iterator to the start of the underlying sequence&period;
| xref:BloombergLP/bslstl/operator_lt.adoc[`operator&lt;`]
| Return `true` if (1) the specified `lhs` iterator refers to an element before the specified `rhs` iterator in the iteration sequence, or (2) `rhs` (and not `lhs`) has the past&hyphen;the&hyphen;end value for an iterator over this sequence, and `false` otherwise&period; The behavior is undefined unless `lhs` and `rhs` are iterators into the same underlying sequence&period;
| xref:BloombergLP/bslstl/operator_le.adoc[`operator&lt;&equals;`]
| Return `true` if (1) the specified `lhs` iterator has the same value as the specified `rhs` iterator, or (2) `lhs` refers to an element before `rhs` in the iteration sequence, or (3) `rhs` has the past&hyphen;the&hyphen;end value for an iterator over this sequence, and `false` otherwise&period; The behavior is undefined unless `lhs` and `rhs` are iterators into the same underlying sequence&period;
| xref:BloombergLP/bslstl/operator_eq-066.adoc[`operator&equals;&equals;`]
| Return `true` if the specified `lhs` iterator has the same value as the specified `rhs` iterator, and `false` otherwise&period; Two iterators have the same value if they refer to the same element, or both have the past&hyphen;the&hyphen; end value for the underlying sequence&period; The behavior is undefined unless both iterators refer to the same underlying sequence&period;
| xref:BloombergLP/bslstl/operator_eq-08.adoc[`operator&equals;&equals;`]
| Return `true` if the specified `lhs` iterator has the same value as the specified `rhs` iterator, and `false` otherwise&period; Two iterators have the same value if they refer to the same element, or both have the past&hyphen;the&hyphen; end value for the underlying sequence&period; The behavior is undefined unless both iterators refer to the same underlying sequence&period;
| xref:BloombergLP/bslstl/operator_eq-0c7.adoc[`operator&equals;&equals;`]
| Return `true` if the specified `lhs` iterator has the same value as the specified `rhs` iterator, and `false` otherwise&period; Two iterators have the same value if they refer to the same element, or both have the past&hyphen;the&hyphen; end value for the underlying sequence&period; The behavior is undefined unless both iterators refer to the same underlying sequence&period;
| xref:BloombergLP/bslstl/operator_gt.adoc[`operator&gt;`]
| Return `true` if (1) the specified `lhs` iterator refers to an element after the specified `rhs` iterator in the iteration sequence, or (2) `lhs` (and not `rhs`) has the past&hyphen;the&hyphen;end value for an iterator over this sequence, and `false` otherwise&period; The behavior is undefined unless `lhs` and `rhs` are iterators into the same underlying sequence&period;
| xref:BloombergLP/bslstl/operator_ge.adoc[`operator&gt;&equals;`]
| Return `true` if (1) the specified `lhs` iterator has the same value as the specified `rhs` iterator, or (2) `lhs` has the past&hyphen;the&hyphen;end value for an iterator over this sequence, or (3) `lhs` refers to an element after `rhs` in the iteration sequence, and `false` otherwise&period; The behavior is undefined unless `lhs` and `rhs` are iterators into the same underlying sequence&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
