template< class C >
auto rbegin( C& c ) -> decltype(c.rbegin());
template< class C >
auto rbegin( const C& c ) -> decltype(c.rbegin());
template< class C >
auto crbegin( const C& c ) -> decltype(std::rbegin(c));
Returns an iterator to the reverse-beginning of the given range.
1,2) Returns c.rbegin(), which is typically an iterator to the reverse-beginning 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::rbegin(c), with c always 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 arbegin
member function array - an array of arbitrary type il - an std::initializer_list [edit] Return value
1,2) c.rbegin()
5) c.rbegin()
[edit] ExceptionsMay throw implementation-defined exceptions.
[edit] OverloadsCustom overloads of rbegin
may be provided for classes and enumerations that do not expose a suitable rbegin()
member function, yet can be iterated.
The overload for std::initializer_list is necessary because it does not have a member function rbegin
.
#include <iostream> #include <iterator> #include <vector> int main() { std::vector<int> v = {3, 1, 4}; auto vi = std::rbegin(v); // the type of âviâ is std::vector<int>::reverse_iterator std::cout << "*vi = " << *vi << '\n'; *std::rbegin(v) = 42; // OK: after assignment v[2] == 42 // *std::crbegin(v) = 13; // error: the location is read-only int a[] = {-5, 10, 15}; auto ai = std::rbegin(a); // the type of âaiâ is std::reverse_iterator<int*> std::cout << "*ai = " << *ai << '\n'; auto il = {3, 1, 4}; // the type of âitâ below is std::reverse_iterator<int const*>: for (auto it = std::rbegin(il); it != std::rend(il); ++it) std::cout << *it << ' '; std::cout << '\n'; }
Output:
[edit] See also returns an iterator to the beginning of a container or arrayRetroSearch 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