std::list<T,Allocator>::front
来自cppreference.com
reference front(); | (1) | (C++26 起为 constexpr) |
const_reference front()const; | (2) | (C++26 起为 constexpr) |
返回到容器首元素的引用。
如果 empty() 是 true,那么行为未定义。 | (C++26 前) |
如果 empty() 是 true,那么: | (C++26 起) |
目录 |
[编辑]返回值
到首元素的引用。
[编辑]复杂度
常数。
[编辑]注解
对于容器 c,表达式 c.front() 等价于 *c.begin()。
[编辑]示例
下列代码用 front
显示 std::list<char> 的首元素:
运行此代码
[编辑]参阅
访问最后一个元素 (公开成员函数) | |
(C++11) | 返回指向末尾的逆向迭代器 (公开成员函数) |
(C++11) | 返回指向起始的迭代器 (公开成员函数) |