std::set<Key,Compare,Allocator>::rbegin, std::set<Key,Compare,Allocator>::crbegin
来自 cppreference.cn
reverse_iterator rbegin(); |
(1) | (noexcept since C++11) |
const_reverse_iterator rbegin() const; |
(2) | (noexcept since C++11) |
const_reverse_iterator crbegin() const noexcept; |
(3) | (since C++11) |
返回指向反向 set
的首元素的逆向迭代器。它对应于非反向 set
的末元素。如果 set
为空,则返回的迭代器等于 rend()。
内容 |
[编辑] 返回值
指向首元素的逆向迭代器。
[编辑] 复杂度
常数。
[编辑] 注解
由于 iterator
和 const_iterator
都是常量迭代器(并且实际上可能是同一类型),因此无法通过这些成员函数返回的迭代器来改变容器的元素。
返回的逆向迭代器的底层迭代器是end 迭代器。 因此,如果末尾迭代器失效,则返回的迭代器也会失效。
libc++ 将 crbegin()
向后移植到 C++98 模式。
[编辑] 示例
运行此代码
输出
⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼
[编辑] 参见
(C++11) |
返回指向末尾的逆向迭代器 (public member function) |
(C++14) |
返回指向容器或数组开头的逆向迭代器 (function template) |