template< class C >
auto rend( C& c ) -> decltype(c.rend());
template< class C >
auto rend( const C& c ) -> decltype(c.rend());
template< class C >
auto crend( const C& c ) -> decltype(std::rend(c));
Returns an iterator to the reverse-end of the given range.
1,2) Returns c.rend(), which is typically an iterator one past the reverse-end of the sequence represented by c.
1)If
C
is a standard
Container, returns a
C::reverse_iterator
object.
2)If
C
is a standard
Container, returns a
C::const_reverse_iterator
object.
5)Returns
std::end(c), with
calways treated as const-qualified.
If
C
is a standard
Container, returns a
C::const_reverse_iterator
object.
[edit] Parameters c - a container or view with arend
member function array - an array of arbitrary type il - an std::initializer_list [edit] Return value
1,2) c.rend()
5) c.rend()
[edit] ExceptionsMay throw implementation-defined exceptions.
[edit] OverloadsCustom overloads of rend
may be provided for classes and enumerations that do not expose a suitable rend()
member function, yet can be iterated.
The overload for std::initializer_list is necessary because it does not have a member function rend
.
#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 4 std::initializer_list `il` backwards: 4 1 3 std::vector `v` backwards: 10 9 -3 6 4[edit] See also returns an iterator to the end of a container or array
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4