GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::rbegin,std::crbegin(3) C++ Standard Libary std::rbegin,std::crbegin(3)

std::rbegin,std::crbegin - std::rbegin,std::crbegin


Defined in header <array>
Defined in header <deque>
Defined in header <forward_list>
Defined in header <iterator>
Defined in header <list>
Defined in header <map>
Defined in header <regex>
Defined in header <set>
Defined in header <span> (since
C++20)
Defined in header <string>
Defined in header <string_view> (since
C++17)
Defined in header <unordered_map>
Defined in header <unordered_set>
Defined in header <vector>
template< class C > (since
auto rbegin( C& c ) -> C++14)
decltype(c.rbegin()); (until
C++17)
template< class C > (since
constexpr auto rbegin( C& c ) -> C++17)
decltype(c.rbegin());
template< class C > (since
auto rbegin( const C& c ) -> C++14)
decltype(c.rbegin()); (until
C++17)
template< class C > (since
constexpr auto rbegin( const C& c C++17)
) -> decltype(c.rbegin());
template< class T, std::size_t N > (since
std::reverse_iterator<T*> rbegin( C++14)
T (&array)[N] ); (until
C++17)
template< class T, std::size_t N > (1)
constexpr (since
std::reverse_iterator<T*> rbegin( C++17)
T (&array)[N] );
template< class T > (1) (since
std::reverse_iterator<const T*> C++14)
rbegin( std::initializer_list<T> (until
il ); (2) C++17)
template< class T >
constexpr (since
std::reverse_iterator<const T*> C++17)
rbegin(std::initializer_list<T> (3)
il);
template< class C > (since
auto crbegin( const C& c ) -> C++14)
decltype(std::rbegin(c)); (until
(4) C++17)
template< class C > (since
constexpr auto crbegin( const C& c C++17)
) -> decltype(std::rbegin(c));


Returns an iterator to the reverse-beginning of the given range.


1) Returns an iterator to the reverse-beginning of the possibly const-qualified
container or view c.
2) Returns std::reverse_iterator<T*> to the reverse-beginning of the array array.
3) Returns std::reverse_iterator<const T*> to the reverse-beginning of the
std::initializer_list il.
4) Returns an iterator to the reverse-beginning of the const-qualified container or
view c.


range-rbegin-rend.svg


c - a container or view with a rbegin member function
array - an array of arbitrary type
il - an initializer_list


1) c.rbegin()
2) std::reverse_iterator<T*>(array + N)
3) std::reverse_iterator<const T*>(il.end())
4) c.rbegin()


May throw implementation-defined exceptions.


Overloads


Custom overloads of rbegin may be provided for classes and enumerations that do not
expose a suitable rbegin() member function, yet can be iterated.


Overloads of rbegin found by argument-dependent lookup can be used to
customize the behavior of std::ranges::rbegin and (since C++20)
std::ranges::crbegin.


The overload for std::initializer_list is necessary because it does not have a
member function rbegin.

// Run this code


#include <iostream>
#include <vector>
#include <iterator>


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 << ' ';
}


*vi = 4
*ai = 15
4 1 3


begin
cbegin returns an iterator to the beginning of a container or array
(C++11) (function template)
(C++14)
end
cend returns an iterator to the end of a container or array
(C++11) (function template)
(C++14)
rend returns a reverse end iterator for a container or array
crend (function template)
(C++14)
ranges::rbegin returns a reverse iterator to a range
(C++20) (customization point object)
ranges::crbegin returns a reverse iterator to a read-only range
(C++20) (customization point object)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.