24 Containers library [containers]

24.2 Requirements [container.requirements]

24.2.2 General containers [container.gen.reqmts]

24.2.2.3 Reversible container requirements [container.rev.reqmts]

A type X meets the reversible container requirements if X meets the container requirements, the iterator type of X belongs to the bidirectional or random access iterator categories ([iterator.requirements]), and the following types and expressions are well-formed and have the specified semantics.
typename X::reverse_iterator
Result: The type reverse_­iterator<X​::​iterator>, an iterator type whose value type is T.
typename X::const_reverse_iterator
Result: The type reverse_­iterator<X​::​const_­iterator>, a constant iterator type whose value type is T.
a.rbegin()
Result: reverse_­iterator; const_­reverse_­iterator for constant a.
Returns: reverse_­iterator(end())
Complexity: Constant.
a.rend()
Result: reverse_­iterator; const_­reverse_­iterator for constant a.
Returns: reverse_­iterator(begin())
Complexity: Constant.
a.crbegin()
Result: const_­reverse_­iterator.
Returns: const_­cast<X const&>(a).rbegin()
Complexity: Constant.
a.crend()
Result: const_­reverse_­iterator.
Returns: const_­cast<X const&>(a).rend()
Complexity: Constant.
Unless otherwise specified (see [associative.reqmts.except], [unord.req.except], [deque.modifiers], and [vector.modifiers]) all container types defined in this Clause meet the following additional requirements:
  • if an exception is thrown by an insert() or emplace() function while inserting a single element, that function has no effects.
  • if an exception is thrown by a push_­back(), push_­front(), emplace_­back(), or emplace_­front() function, that function has no effects.
  • no erase(), clear(), pop_­back() or pop_­front() function throws an exception.
  • no copy constructor or assignment operator of a returned iterator throws an exception.
  • no swap() function throws an exception.
  • no swap() function invalidates any references, pointers, or iterators referring to the elements of the containers being swapped.
    [Note 1:
    The end() iterator does not refer to any element, so it can be invalidated.
    — end note]
Unless otherwise specified (either explicitly or by defining a function in terms of other functions), invoking a container member function or passing a container as an argument to a library function shall not invalidate iterators to, or change the values of, objects within that container.
A contiguous container is a container whose member types iterator and const_­iterator meet the Cpp17RandomAccessIterator requirements ([random.access.iterators]) and model contiguous_­iterator ([iterator.concept.contiguous]).