std::set<Key,Compare,Allocator>::rend, std::set<Key,Compare,Allocator>::crend

来自cppreference.com
< cpp‎ | container‎ | set
 
 
 
 
reverse_iterator rend();
(1) (C++11 起为 noexcept)
(C++26 起为 constexpr)
const_reverse_iterator rend()const;
(2) (C++11 起为 noexcept)
(C++26 起为 constexpr)
const_reverse_iterator crend()constnoexcept;
(3) (C++11 起)
(C++26 起为 constexpr)

返回指向逆向的 *this 的尾后元素的逆向迭代器。它对应非逆向的 *this 的首元素的前一元素。

返回的迭代器仅表现为哨位。不保证它可解引用

range-rbegin-rend.svg

目录

[编辑]返回值

指向尾后元素的逆向迭代器。

[编辑]复杂度

常数。

[编辑]示例

#include <iostream>#include <set>   int main(){std::set<unsigned> rep{1, 2, 3, 4, 1, 2, 3, 4};   for(auto it = rep.crbegin(); it != rep.crend();++it){for(auto n =*it; n >0;--n)std::cout<<"⏼"<<' ';std::cout<<'\n';}}

输出:

⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼

[编辑]参阅

返回指向起始的逆向迭代器
(公开成员函数)[编辑]
(C++14)
返回容器或数组的逆向尾迭代器
(函数模板)[编辑]
close