std::set<Key,Compare,Allocator>::rend, std::set<Key,Compare,Allocator>::crend
来自 cppreference.cn
reverse_iterator rend(); |
(1) | (C++11 起无异常抛出) |
const_reverse_iterator rend() const; |
(2) | (C++11 起无异常抛出) |
const_reverse_iterator crend() const noexcept; |
(3) | (C++11 起) |
返回一个反向迭代器,指向反向 set
中最后一个元素之后的元素。它对应于非反向 set
中第一个元素之前的元素。此元素充当占位符,尝试访问它会导致未定义行为。
目录 |
[编辑] 返回值
指向最后一个元素之后位置的逆向迭代器。
[编辑] 复杂度
常数时间。
注意
由于 iterator
和 const_iterator
都是常量迭代器(实际上可能是同一类型),因此无法通过这些成员函数返回的迭代器修改容器的元素。
libc++ 将 crend()
反向移植到 C++98 模式。
[编辑] 示例
运行此代码
输出
⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼
[编辑] 参阅
(C++11) |
返回指向起始的逆向迭代器 (公共成员函数) |
(C++14) |
返回容器或数组的反向结束迭代器 (函数模板) |