首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::crbegin

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

返回值

的反向开头的迭代器。carray...

注记

除了被纳入<iterator>,,,std::rbeginstd::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)

二次

代码语言:javascript
复制
#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';
}

二次

产出:

二次

代码语言:javascript
复制
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)

代码语言:txt
复制
 ? cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com