std::forwar...::pop_front(3)
π NAME π
okay so bestie, this is the std::forwar...::pop_front(3) page from the C++ Standard Libary manual (yes, that's the spelling on the page β don't come for me π). The NAME line is out here being extra: std::forward_list::pop_front β std::forward_list::pop_front. She's the function that pops the front element of a std::forward_list. Main character energy only. π
β¨ Synopsis β¨
void pop_front(); (since C++11)
Translation: she removes the first element of the container. That's the move. But if there are no elements in the container, the behavior is undefined β like, full stop, undefined. Do not pass go, do not collect vibes. π«
Also important: references and iterators to the erased element are invalidated. So if you had a ref or iterator to that first element, after the pop it's invalidated. No cap. π¦
πΈ Parameters πΈ
(none) β no arguments, no drama. She takes nothing. π
π Return value π
(none) β returns nothing. Does the thing and leaves. Iconic. π
β‘ Complexity β‘
Constant. Literally constant. No scaling arc. β¨
π¦ Exceptions π¦
Does not throw. Periodt. π
π Example π
The page drops // Run this code, so run this code, bestie:
// Run this code
#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";
}
Output:
chars.front(): 'A'
chars.front(): 'B'
chars.front(): 'C'
chars.front(): 'D'
π See also π
push_frontβ inserts an element to the beginning (public member function). The opposite-direction bestie. π«Άfrontβ access the first element (public member function). The peek before the pop, iykyk. π
mwah π β source: http://cppreference.com, version/date: 2024.06.10. That's the whole page, bestie. Slay forever. ππ
π¦ 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