[#BloombergLP-bslstl-RandomAccessIterator] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslstl.adoc[bslstl]::RandomAccessIterator :relfileprefix: ../../ :mrdocs: Given an `ITER_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 "random‐access iterator" in the C++ standard. If `T` is const‐qualified, then the resulting type is a const iterator. `T` shall not be a function, reference type or void. `ITER_IMP` must provide public operations so that, for objects `i` and `j` of type `ITER_IMP` and `n` of an integral type, the following operations are supported: ` ITER_IMP i; default construction ITER_IMP j(i); copy construction i = j assignment ++i increment to next element ‐‐i decrement to previous element i += n increment by n elements i ‐= n decrement by n elements j ‐ i // convertible to ptrdiff_t distance from i to j i == j // convertible to bool equality comparison i < j // convertible to bool less‐than comparison *i // reference convertible to T& element access (dereference) ` == Synopsis Declared in `<bslstl_randomaccessiterator.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class T, class ITER_IMP, class TAG_TYPE = std::random_access_iterator_tag> class RandomAccessIterator : public xref:BloombergLP/bslstl/BidirectionalIterator.adoc[BidirectionalIterator<T, ITER_IMP, TAG_TYPE>] ---- == Base Classes [cols="1,4"] |=== | Name| Description | `xref:BloombergLP/bslstl/BidirectionalIterator.adoc[BidirectionalIterator<T, ITER_IMP, TAG_TYPE>]` | Given an `ITER_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 "bidirectional iterator" in the C++ standard. If `T` is `const`‐qualified, then the resulting type is a constant iterator. `T` shall not be a function, reference type or void. `ITER_IMP` must provide public operations so that, for objects `i` and `j` of type `ITER_IMP`, the following operations are supported: ` ITER_IMP i; default construction ITER_IMP j(i); copy construction i = j assignment ++i increment to next element ‐‐i decrement to previous element i == j // convertible to bool equality comparison *i // reference convertible to T& element access (dereference) ` |=== == Type Aliases [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslstl/RandomAccessIterator/difference_type.adoc[`difference_type`] | Signed integer type measuring iterator distance. | xref:BloombergLP/bslstl/RandomAccessIterator/iterator_category.adoc[`iterator_category`] | Random‐access iterator category tag. | xref:BloombergLP/bslstl/RandomAccessIterator/pointer.adoc[`pointer`] | Pointer type for the iterator's value type. | xref:BloombergLP/bslstl/RandomAccessIterator/reference.adoc[`reference`] | Reference type for the iterator's value type. | xref:BloombergLP/bslstl/RandomAccessIterator/value_type.adoc[`value_type`] | Value type referred to by this iterator. |=== == 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=`] | Assignment operators | xref:BloombergLP/bslstl/ForwardIterator/imp-0e.adoc[`imp`] | `imp` overloads | xref:BloombergLP/bslstl/ForwardIterator/operator_star.adoc[`operator*`] | Return a reference to the current, modifiable element. The behavior is undefined if this iterator has the past‐the‐end value for an iterator over the underlying sequence. | xref:BloombergLP/bslstl/RandomAccessIterator/operator_inc.adoc[`operator++`] | Increment to the next element. Return a reference to this modifiable iterator. The behavior is undefined if, on entry, this iterator has the past‐the‐end value for an iterator over the underlying sequence. | xref:BloombergLP/bslstl/RandomAccessIterator/operator_plus_eq.adoc[`operator+=`] | Increment by the specified `offset` number of elements. Return a reference to this modifiable iterator. The behavior is undefined unless the iterator, after incrementing by `offset`, is within the bounds of the underlying sequence. | xref:BloombergLP/bslstl/RandomAccessIterator/operator_dec.adoc[`operator‐‐`] | Decrement to the previous element. Return a reference to this modifiable iterator. The behavior is undefined if, on entry, this iterator has the same value as an iterator to the start of the underlying sequence. | xref:BloombergLP/bslstl/RandomAccessIterator/operator_minus_eq.adoc[`operator‐=`] | Decrement by the specified `offset` number of elements. Return a reference to this modifiable iterator. The behavior is undefined unless the iterator, after decrementing by `offset`, is within the bounds of the underlying sequence. | xref:BloombergLP/bslstl/ForwardIterator/operator_ptr.adoc[`operator‐>`] | Return a pointer to the current, modifiable element. The behavior is undefined if this iterator has the past‐the‐end value for an iterator over the underlying sequence. | xref:BloombergLP/bslstl/RandomAccessIterator/operator_subs.adoc[`operator[]`] | Return a reference to the element at the specified `index` positions past the current one. The behavior is undefined unless the referenced position lies within the underlying sequence. Note that `index` may be negative. |=== == Non-Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslstl/operator_not_eq-093.adoc[`operator!=`] | Return `true` if the specified `lhs` iterator does not have the same value as the specified `rhs` iterator, and `false` otherwise. 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‐the‐end iterator value for the underlying sequence. The behavior is undefined unless both iterators refer to the same underlying sequence. | xref:BloombergLP/bslstl/operator_not_eq-0bc.adoc[`operator!=`] | Return `true` if the specified `lhs` iterator does not have the same value as the specified `rhs` iterator, and `false` otherwise. 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‐the‐end iterator value for the underlying sequence. The behavior is undefined unless both iterators refer to the same underlying sequence. | xref:BloombergLP/bslstl/operator_not_eq-0d.adoc[`operator!=`] | Return `true` if the specified `lhs` iterator does not have the same value as the specified `rhs` iterator, and `false` otherwise. 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‐the‐end iterator value for the underlying sequence. The behavior is undefined unless both iterators refer to the same underlying sequence. | xref:BloombergLP/bslstl/operator_plus-09.adoc[`operator+`] | Return an iterator to the element at the specified `rhs` positions past the specified `lhs`. The behavior is undefined unless `lhs`, after incrementing by `rhs`, is within the bounds of the underlying sequence. | xref:BloombergLP/bslstl/operator_plus-0fa.adoc[`operator+`] | Return an iterator to the element at the specified `lhs` positions past the specified `rhs`. The behavior is undefined unless `rhs`, after incrementing by `lhs`, is within the bounds of the underlying sequence. | xref:BloombergLP/bslstl/operator_inc-005.adoc[`operator++`] | Increment the specified `iter` to next element. Return the previous value of `iter`. The behavior is undefined if, on entry, `iter` has the past‐the‐end value for an iterator of the underlying sequence. | xref:BloombergLP/bslstl/operator_inc-008.adoc[`operator++`] | Increment the specified `iter` to the next element. Return the previous value of `iter`. The behavior is undefined if, on entry, `iter` has the past‐the‐end value for an iterator of the underlying sequence. | xref:BloombergLP/bslstl/operator_inc-07.adoc[`operator++`] | Increment the specified `iter` to the next element. Return the previous value of `iter`. The behavior is undefined if, on entry, `iter` has the past‐the‐end value for an iterator of the underlying sequence. | xref:BloombergLP/bslstl/operator_minus-02.adoc[`operator‐`] | Return an iterator to the element at the specified `rhs` positions before the specified `lhs`. The behavior is undefined unless `lhs`, after decrementing by `rhs`, is within the bounds of the underlying sequence. Note that this function is logically equivalent to: ` iter + (‐rhs) ` | xref:BloombergLP/bslstl/operator_minus-0b.adoc[`operator‐`] | Return the distance from the specified `rhs` iterator to the specified `lhs` iterator. The behavior is undefined unless `lhs` and `rhs` are iterators into the same underlying sequence. Note that the result might be negative. | xref:BloombergLP/bslstl/operator_dec-05.adoc[`operator‐‐`] | Decrement the specified `iter` to previous element. Return the previous value of `iter`. The behavior is undefined if, on entry, `iter` has the same value as an iterator to the start of the underlying sequence. | xref:BloombergLP/bslstl/operator_dec-08.adoc[`operator‐‐`] | Decrement the specified `iter` to the previous element. Return the previous value of `iter`. The behavior is undefined if, on entry, `iter` has the same value as an iterator to the start of the underlying sequence. | xref:BloombergLP/bslstl/operator_lt.adoc[`operator<`] | 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‐the‐end value for an iterator over this sequence, and `false` otherwise. The behavior is undefined unless `lhs` and `rhs` are iterators into the same underlying sequence. | xref:BloombergLP/bslstl/operator_le.adoc[`operator<=`] | 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‐the‐end value for an iterator over this sequence, and `false` otherwise. The behavior is undefined unless `lhs` and `rhs` are iterators into the same underlying sequence. | xref:BloombergLP/bslstl/operator_eq-066.adoc[`operator==`] | Return `true` if the specified `lhs` iterator has the same value as the specified `rhs` iterator, and `false` otherwise. Two iterators have the same value if they refer to the same element, or both have the past‐the‐ end value for the underlying sequence. The behavior is undefined unless both iterators refer to the same underlying sequence. | xref:BloombergLP/bslstl/operator_eq-08.adoc[`operator==`] | Return `true` if the specified `lhs` iterator has the same value as the specified `rhs` iterator, and `false` otherwise. Two iterators have the same value if they refer to the same element, or both have the past‐the‐ end value for the underlying sequence. The behavior is undefined unless both iterators refer to the same underlying sequence. | xref:BloombergLP/bslstl/operator_eq-0c7.adoc[`operator==`] | Return `true` if the specified `lhs` iterator has the same value as the specified `rhs` iterator, and `false` otherwise. Two iterators have the same value if they refer to the same element, or both have the past‐the‐ end value for the underlying sequence. The behavior is undefined unless both iterators refer to the same underlying sequence. | xref:BloombergLP/bslstl/operator_gt.adoc[`operator>`] | 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‐the‐end value for an iterator over this sequence, and `false` otherwise. The behavior is undefined unless `lhs` and `rhs` are iterators into the same underlying sequence. | xref:BloombergLP/bslstl/operator_ge.adoc[`operator>=`] | Return `true` if (1) the specified `lhs` iterator has the same value as the specified `rhs` iterator, or (2) `lhs` has the past‐the‐end value for an iterator over this sequence, or (3) `lhs` refers to an element after `rhs` in the iteration sequence, and `false` otherwise. The behavior is undefined unless `lhs` and `rhs` are iterators into the same underlying sequence. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#