std::
forward_list::pop_front
公众成员函数 <forward_list>
删除第一个元素
移除forward_list容器中的第一个元素,其大小减少1。
移除的元素被析构。
☲ 参数
-
none
☉ 返回值
none
☣ 示例
// forward_list::pop_front
#include <iostream>
#include <forward_list>
int main ()
{
std::forward_list<int> mylist = {10, 20, 30, 40};
std::cout << "Popping out the elements in mylist:";
while (!mylist.empty())
{
std::cout << ' ' << mylist.front();
mylist.pop_front();
}
std::cout << '\n';
return 0;
} |
输出:
Popping out the elements in mylist: 10 20 30 40
✥ 复杂度
常量
☣ 迭代器的有效性
指向被函数移除的元素的迭代器、指针和引用将失效。
所有其他迭代器、指针和引用保持其有效性。
⇄ 数据竞争
容器被修改。
修改了第一个元素。并发访问或修改其他元素是安全的。
☂ 异常安全性
如果容器不是空的,函数永远不会抛出异常(no-throw保证)。
否则,它将导致未定义的行为。
🍄 另请参阅
forward_list::emplace_front |
构造并在开头插入元素(公众成员函数) |
forward_list::push_front |
在开头插入元素 (公众成员函数) |
forward_list::remove |
删除具有特定值的元素(公众成员函数) |
forward_list::clear |
清除内容(公众成员函数) |
forward_list::resize |
改变大小(公众成员函数) |