std::forward_list<T,Allocator>::pop_front
來自 cppreference.com
< cpp | 容器 | forward_list
void pop_front(); |
(C++11 起) | |
移除容器的首元素。如果容器中沒有元素,則行為未定義。
對被擦除元素的引用和迭代器將失效。
[編輯] 複雜度
常數時間。
[編輯] 示例
執行此程式碼
#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'
[編輯] 參閱
插入元素到起始 (public member function) | |
訪問第一個元素 (public member function) |