std::list::pop_front(3)
std::list::pop_front(3) π
okay so this is the std::list::pop_front page from the C++ Standard Libary manual (yes, that's the manual's spelling, bestie β not my typo π
). She's short, she's iconic, and she's here to remove exactly one thing from the front of your list.
πΈ NAME πΈ
std::list::pop_front β std::list::pop_front (she said what she said, and honestly? slay β¨).
β¨ Synopsis β¨
void pop_front();
She removes the first element of the container. But bestie, listen: if there are no elements in the container, the behavior is undefined. That's undefined behavior territory, no cap β not a vibe to mess around with π.
Also important: references and iterators to the erased element are invalidated. They're done, they're invalidated, they're not coming to the group chat anymore π.
π«Ά Parameters π«Ά
- (none) β literally nothing. No arguments, no little extras, no notes. She's low-maintenance π.
π Return value π
- (none) β she returns nothing. The removal is the moment, and the moment is enough β¨.
π¦ Complexity π¦
Constant. Quick, constant, no drama β the way we like it π .
π Exceptions π
Does not throw. She's not throwing hands, she's not throwing exceptions. She's just popping the front and minding her business π.
π Example π
// Run this code
#include <list>
#include <iostream>
int main()
{
std::list<char> chars{'A', 'B', 'C', 'D'};
for (; !chars.empty(); chars.pop_front())
std::cout << "chars.front(): '" << chars.front() << "'\n";
}
β Output β
chars.front(): 'A'
chars.front(): 'B'
chars.front(): 'C'
chars.front(): 'D'
π See also π
pop_backβ removes the last element (public member function) πpush_frontβ inserts an element to the beginning (public member function) β¨frontβ access the first element (public member function) π«Ά
that's the whole page, bestie π β brought to you by source/version http://cppreference.com, dated 2024.06.10, signing off with maximum sparkle π§β¨π¦
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms