std::rend,std::crend (3) - Linux Manuals
std::rend,std::crend: std::rend,std::crend
NAME
std::rend,std::crend - std::rend,std::crend
Synopsis
Defined in header <iterator>
template< class C > (since C++14)
auto rend( C& c ) -> decltype(c.rend()); (until C++17)
template< class C > (since C++17)
constexpr auto rend( C& c ) -> decltype(c.rend());
template< class C > (since C++14)
auto rend( const C& c ) -> decltype(c.rend()); (until C++17)
template< class C > (since C++17)
constexpr auto rend( const C& c ) -> decltype(c.rend()); (1)
template< class T, size_t N > (since C++14)
reverse_iterator<T*> rend( T (&array)[N] ); (1) (until C++17)
template< class T, size_t N > (since C++17)
constexpr reverse_iterator<T*> rend( T (&array)[N] ); (2)
template< class C > (since C++14)
auto crend( const C& c ) -> decltype(std::rend(c)); (3) (until C++17)
template< class C > (since C++17)
constexpr auto crend( const C& c ) -> decltype(std::rend(c));
Returns an iterator to the reverse-end of the given container c or array array.
1) Returns a possibly const-qualified iterator to the reverse-end of the container c.
2) Returns std::reverse_iterator<T*> to the reverse-end of the array array.
3) Returns a const-qualified iterator to the reverse-end of the container c.
range-rbegin-rend.svg
Parameters
c - a container with a rend method
array - an array of arbitrary type
Return value
An iterator to the reverse-end of c or array
Notes
In addition to being included in <iterator>, std::rend and std::crend are guaranteed to become available if any of the following headers are included: <array>, <deque>, <forward_list>, <list>, <map>, <regex>, <set>
, <span>
(since C++20), <string>
, <string_view>
(since C++17), <unordered_map>, <unordered_set>, and <vector>.
Overloads
Custom overloads of rend may be provided for classes that do not expose a suitable rend() member function, yet can be iterated. The following overload is already provided by the standard library:
rend(std::initializer_list) specializes std::rend
(C++14)
Example
// Run this code
Output:
See also
end
cend returns an iterator to the end of a container or array
(C++11)
(C++14)
rbegin returns a reverse iterator to a container or array
crbegin (function template)
(C++14)
begin
cbegin returns an iterator to the beginning of a container or array
(C++11)
(C++14)