std::set<Key,Compare,Allocator>::rend, std::set<Key,Compare,Allocator>::crend
来自cppreference.com
<tbody>
</tbody>
reverse_iterator rend(); |
(1) | (C++11 起为 noexcept) |
const_reverse_iterator rend() const; |
(2) | (C++11 起为 noexcept) |
const_reverse_iterator crend() const noexcept; |
(3) | (C++11 起) |
返回指向逆向的 set 末元素后一元素的逆向迭代器。它对应非逆向 set 首元素的前一元素。此元素表现为占位符,试图访问它导致未定义行为。
返回值
指向末元素后一元素的逆向迭代器。
复杂度
常数。
示例
运行此代码
#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++11) |
返回指向起始的逆向迭代器 (公开成员函数) |
(C++14) |
返回容器或数组的逆向尾迭代器 (函数模板) |