Category: containers | Component type: concept |
Reverse iterator type | X::reverse_iterator | A Reverse Iterator adaptor whose base iterator type is the container's iterator type. Incrementing an object of type reverse_iterator moves backwards through the container: the Reverse Iterator adaptor maps operator++ to operator--. |
Const reverse iterator type | X::const_reverse_iterator | A Reverse Iterator adaptor whose base iterator type is the container's const iterator type. [1] |
X | A type that is a model of Reversible Container |
a, b | Object of type X |
Name | Expression | Type requirements | Return type |
---|---|---|---|
Beginning of range | a.rbegin() | reverse_iterator if a is mutable, const_reverse_iterator otherwise [1] | |
End of range | a.rend() | reverse_iterator if a is mutable, const_reverse_iterator otherwise [1] |
Name | Expression | Precondition | Semantics | Postcondition |
---|---|---|---|---|
Beginning of reverse range | a.rbegin() | Equivalent to X::reverse_iterator(a.end()). | a.rbegin() is dereferenceable or past-the-end. It is past-the-end if and only if a.size() == 0. | |
End of reverse range | a.rend() | Equivalent to X::reverse_iterator(a.begin()). | a.end() is past-the-end. |
Valid range | [a.rbegin(), a.rend()) is a valid range. |
Equivalence of ranges | The distance from a.begin() to a.end() is the same as the distance from a.rbegin() to a.rend(). |
[1] A Container's iterator type and const iterator type may be the same type: a container need not provide mutable iterators. It follows from this that the reverse iterator type and the const reverse iterator type may also be the same.