| Iterator concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator primitives | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Algorithm concepts and utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Indirect callable concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Common algorithm requirements | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator adaptors | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Defined in header <array> | ||
Defined in header <deque> | ||
Defined in header <flat_map> | ||
Defined in header <flat_set> | ||
Defined in header <forward_list> | ||
Defined in header <inplace_vector> | ||
Defined in header <iterator> | ||
Defined in header <list> | ||
Defined in header <map> | ||
Defined in header <regex> | ||
Defined in header <set> | ||
Defined in header <span> | ||
Defined in header <string> | ||
Defined in header <string_view> | ||
Defined in header <unordered_map> | ||
Defined in header <unordered_set> | ||
Defined in header <vector> | ||
template<class C> auto rend( C& c)-> decltype(c.rend()); | (1) | (since C++14) (constexpr since C++17) |
template<class C> auto rend(const C& c)-> decltype(c.rend()); | (2) | (since C++14) (constexpr since C++17) |
template<class T,std::size_t N> std::reverse_iterator<T*> rend( T(&array)[N]); | (3) | (since C++14) (constexpr since C++17) |
template<class T> std::reverse_iterator<const T*> rend(std::initializer_list<T> il); | (4) | (since C++14) (constexpr since C++17) |
template<class C> auto crend(const C& c)-> decltype(std::rend(c)); | (5) | (since C++14) (constexpr since C++17) |
Returns an iterator to the reverse-end of the given range.
Contents |
| c | - | a container or view with arend member function |
| array | - | an array of arbitrary type |
| il | - | anstd::initializer_list |
May throw implementation-defined exceptions.
Custom overloads ofrend may be provided for classes and enumerations that do not expose a suitablerend() member function, yet can be iterated.
Overloads of | (since C++20) |
The overload forstd::initializer_list is necessary because it does not have a member functionrend.
#include <algorithm>#include <iostream>#include <iterator>#include <vector> int main(){int a[]{4,6,-3,9,10};std::cout<<"C-style array `a` backwards: ";std::copy(std::rbegin(a), std::rend(a),std::ostream_iterator<int>(std::cout," ")); auto il={3,1,4};std::cout<<"\nstd::initializer_list `il` backwards: ";std::copy(std::rbegin(il), std::rend(il),std::ostream_iterator<int>(std::cout," ")); std::vector<int> v{4,6,-3,9,10};std::cout<<"\nstd::vector `v` backwards: ";std::copy(std::rbegin(v), std::rend(v),std::ostream_iterator<int>(std::cout," "));std::cout<<'\n';}
Output:
C-style array `a` backwards: 10 9 -3 6 4std::initializer_list `il` backwards: 4 1 3std::vector `v` backwards: 10 9 -3 6 4
(C++11)(C++14) | returns an iterator to the end of a container or array (function template)[edit] |
(C++14) | returns a reverse iterator to the beginning of a container or array (function template)[edit] |
(C++11)(C++14) | returns an iterator to the beginning of a container or array (function template)[edit] |
(C++20) | returns a reverse end iterator to a range (customization point object)[edit] |
(C++20) | returns a reverse end iterator to a read-only range (customization point object)[edit] |