std::forward_list<T,Allocator>:: pop_front
From cppreference.net
<
cpp
|
container
|
forward list
C++
Containers library
|
(C++17)
|
||||
| Sequence | ||||
|
(C++11)
|
||||
|
(C++26)
|
||||
|
(C++26)
|
||||
|
(C++11)
|
||||
| Associative | ||||
| Unordered associative | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| Adaptors | ||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
| Views | ||||
|
(C++20)
|
||||
|
(C++23)
|
||||
| Tables | ||||
| Iterator invalidation | ||||
| Member function table | ||||
| Non-member function table |
std::forward_list
| Member functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Non-member functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Deduction guides (C++17) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
void
pop_front
(
)
;
|
(自 C++11 起)
(自 C++26 起为 constexpr) |
|
移除容器的首个元素。
|
如果 empty() 为 true ,则行为未定义。 |
(C++26 前) |
|
如果 empty() 为 true : |
(C++26 起) |
对被擦除元素的引用和迭代器将失效。
复杂度
常量。
示例
运行此代码
#include <forward_list> #include <iostream> int main() { std::forward_list<char> chars{'A', 'B', 'C', 'D'}; for (; !chars.empty(); chars.pop_front()) std::cout << "chars.front(): '" << chars.front() << "'\n"; }
输出:
chars.front(): 'A' chars.front(): 'B' chars.front(): 'C' chars.front(): 'D'
参见
|
在开头插入元素
(公开成员函数) |
|
|
访问首元素
(公开成员函数) |