Defined in header <iterator> | ||||
---|---|---|---|---|
| (1) | (since C++14) | ||
| (1) | (since C++14) | ||
| (2) | (since C++14) | ||
| (3) | (since C++14) |
Returns an iterator to the reverse-beginning of the given container c
or array array
.
1) Returns a possibly const-qualified iterator to the reverse-beginning of the container
c
. 3) Returns a const-qualified iterator to the reverse-beginning of the container
c
.Parameters
c | - | a container with a rbegin method |
array | - | an array of arbitrary type |
Return value
An iterator to the reverse-beginning of c
or array
.
Notes
In addition to being included in <iterator>
, std::rbegin
is guaranteed to become available if any of the following headers are included: <array>
, <deque>
, <forward_list>
, <list>
, <map>
, <regex>
, <set>
, <string>
, <unordered_map>
, <unordered_set>
, and <vector>
.
Specializations
Custom specializations of std::rbegin
may be provided for classes that do not expose a suitable rbegin()
member function, yet can be iterated. The following specialization is already provided by the standard library:
(C++14) | specializes std::rbegin (function) |
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #include <iostream> #include <vector> #include <iterator> int main() { std::vector< int > v = { 3, 1, 4 }; auto vi = std::rbegin(v); std::cout << *vi << '\n' ; int a[] = { -5, 10, 15 }; auto ai = std::rbegin(a); std::cout << *ai << '\n' ; } |
Output:
1 2 | 4 15 |
See also
(C++11)(C++14) | returns an iterator to the beginning of a container or array (function) |
(C++11)(C++14) | returns an iterator to the end of a container or array (function) |
(C++14) | returns a reverse end iterator for a container or array (function) |
Please login to continue.