(C++17) | ||||
| Sequence | ||||
(C++11) | ||||
(C++26) | ||||
(C++26) | ||||
(C++11) | ||||
| Associative | ||||
| Unordered associative | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
| Adaptors | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
| Views | ||||
(C++20) | ||||
(C++23) | ||||
| Tables | ||||
| Iterator invalidation | ||||
| Member function table | ||||
| Non-member function table |
| Member types | |||||||||||||||||||||||||||
| Member functions | |||||||||||||||||||||||||||
| |||||||||||||||||||||||||||
| Non-member functions | |||||||||||||||||||||||||||
| |||||||||||||||||||||||||||
| Helper classes | |||||||||||||||||||||||||||
| Deduction guides(C++17) | |||||||||||||||||||||||||||
reverse_iterator rend()noexcept; | (1) | (since C++11) (constexpr since C++17) |
const_reverse_iterator rend()constnoexcept; | (2) | (since C++11) (constexpr since C++17) |
const_reverse_iterator crend()constnoexcept; | (3) | (since C++11) (constexpr since C++17) |
Returns a reverse iterator past the last element of the reversed*this. It corresponds to the element preceding the first element of the non-reversed*this.
This returned iterator only acts as a sentinel. It is not guaranteed to bedereferenceable.
Contents |
Reverse iterator to the element following the last element.
Constant.
#include <algorithm>#include <iostream>#include <array> int main(){std::array<int,11> a{1,11,11,35,0,12,79,76,76,69,40}; // Print elements of container in reverse order using const_reverse_iterator's.std::for_each(a.crbegin(), a.crend(),[](int e){std::cout<< e<<' ';});std::cout<<'\n'; // Modify each element of container using non-const reverse_iterator's.std::for_each(a.rbegin(), a.rend(),[](int& e){ e+=32;}); // Print elements as chars in reverse order using const_reverse_iterator's.std::for_each(a.crbegin(), a.crend(),[](char e){std::cout<< e;});std::cout<<'\n';}
Output:
40 69 76 76 79 12 0 35 11 11 1Hello, C++!
| returns a reverse iterator to the beginning (public member function)[edit] | |
(C++14) | returns a reverse end iterator for a container or array (function template)[edit] |