std::rbegin
Defined in header <iterator> | | |
|---|---|---|
| (1) | |
template< class C > auto rbegin( C& c ) -> decltype(c.rbegin()); | (since C++14) (until C++17) | |
template< class C > constexpr auto rbegin( C& c ) -> decltype(c.rbegin()); | (since C++17) | |
| (1) | |
template< class C > auto rbegin( const C& c ) -> decltype(c.rbegin()); | (since C++14) (until C++17) | |
template< class C > constexpr auto rbegin( const C& c ) -> decltype(c.rbegin()); | (since C++17) | |
| (2) | |
template< class T, size_t N > reverse_iterator<T*> rbegin( T (&array)N ); | (since C++14) (until C++17) | |
template< class T, size_t N > constexpr reverse_iterator<T*> rbegin( T (&array)N ); | (since C++17) | |
| (3) | |
template< class C > auto crbegin( const C& c ) -> decltype(std::rbegin(c)); | (since C++14) (until C++17) | |
template< class C > constexpr auto crbegin( const C& c ) -> decltype(std::rbegin(c)); | (since C++17) |
将迭代器返回到给定容器的反向开头。c或阵列array...
1%29将可能的const限定迭代器返回到容器的反向开头。c...
2%29std::reverse_iterator<T*>指向数组的反向开头。array...
3%29返回一个Const限定迭代器到容器的反向开头。c...
参数
c | - | a container with a rbegin method |
|---|---|---|
array | - | an array of arbitrary type |
返回值
的反向开头的迭代器。c或array...
注记
除了被纳入<iterator>,,,std::rbegin和std::crbegin如果包括下列任何一个标头,则保证可用:<array>,,,<deque>,,,<forward_list>,,,<list>,,,<map>,,,<regex>,,,<set>,,,<string>,<字符串[医]自C++17%29以来,视图>%28,<unordered_map>,,,<unordered_set>,和<vector>...
过载
自定义超载rbegin可以为不公开合适的类提供rbegin()成员函数,但可以迭代。标准库已经提供了以下重载:
rbegin(std::initializer_list) (C++14) | specializes std::rbegin (function) |
|---|
例
二次
#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';
}二次
产出:
二次
4
15二次
另见
begincbegin (C++11)(C++14) | returns an iterator to the beginning of a container or array (function) |
|---|---|
endcend (C++11)(C++14) | returns an iterator to the end of a container or array (function) |
rendcrend (C++14) | returns a reverse end iterator for a container or array (function) |
© cppreference.com在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

