std::list<T,Allocator>::rbegin, std::list<T,Allocator>::crbegin
来自cppreference.com
容器库
std::list
成员函数 | ||||
元素访问 | ||||
迭代器 | ||||
(C++11)
|
||||
(C++11)
|
||||
list::rbeginlist::crbegin
(C++11)
|
||||
(C++11)
|
||||
容量 | ||||
修改器 | ||||
(C++11)
|
||||
(C++11)
|
||||
(C++11)
|
||||
操作 | ||||
非成员函数 | ||||
(C++20)(C++20)
|
||||
(C++20
前)(C++20
前)(C++20
前)(C++20
前)(C++20
前)(C++20)
|
||||
推导指引(C++17) |
reverse_iterator
rbegin();
|
(C++11 前) | |
reverse_iterator
rbegin()
noexcept;
|
(C++11 起) | |
const_reverse_iterator
rbegin()
const;
|
(C++11 前) | |
const_reverse_iterator
rbegin()
const
noexcept;
|
(C++11 起) | |
const_reverse_iterator
crbegin()
const
noexcept;
|
(C++11 起) | |
返回指向逆向 list
首元素的逆向迭代器。它对应非逆向 list
的末元素。若
list
为空,则返回的迭代器等于 rend() 。
参数
(无)
返回值
指向首元素的逆向迭代器。
复杂度
常数。
示例
运行此代码
#include <iostream> #include <numeric> #include <list> #include <string> int main() { std::list<int> nums {1, 2, 4, 8, 16}; std::list<std::string> fruits {"orange", "apple", "raspberry"}; std::list<char> empty; // 求和 list nums 中的所有整数(若存在),仅打印结果。 std::cout << "Sum of nums: " << std::accumulate(nums.begin(), nums.end(), 0) << "\n"; // 打印 list fruits 中的首个 fruis ,不检查是否有一个。 std::cout << "First fruit: " << *fruits.begin() << "\n"; if (empty.begin() == empty.end()) std::cout << "list 'empty' is indeed empty.\n"; }
输出:
Sum of nums: 31 First fruit: orange list 'empty' is indeed empty.
参阅
(C++11)
|
返回指向末尾的逆向迭代器 (公开成员函数) |