std::deque::pop_front(3)
π std::deque::pop_front(3) π
okay so bestie, welcome to the C++ Standard Libary page β yes, the source really spells it Libary, we are keeping the typo, do not come for me π β and today's main character is std::deque::pop_front. This is the C++ Standard Library manual, and we are about to pop the front element like it is a bad vibe. π
π NAME π
std::deque::pop_front β literally std::deque::pop_front, that is the name, no notes. Periodt. π
π¦ Synopsis π¦
Here is the signature, copy it exactly, no improv:
void pop_front();
Okay so what it does: it removes the first element of the container. That is the whole job. If there are no elements in the container, the behavior is undefined β like, not a cute little no-op, actually undefined behavior. So do not call it on an empty deque and expect magic, bestie. π¨
About iterators and references: iterators and references to the erased element are invalidated. If the element is the last element in the container, the end() iterator is also invalidated. Other references and iterators are not affected. The way that invalidates exactly the erased element and leaves the rest alone? Obsessed. β¨
π«Ά Parameters π«Ά
(none) β not a single parameter, bestie. Zero. Nada. The void is empty. π«Ά
π Return value π
(none) β it returns nothing. No value, no little gift, just the pop. π
β Complexity β
Constant. That is the whole note. Constant. Keep it moving. β
π Exceptions π
Does not throw. It is giving unbothered, no exceptions, no throw. π
πΈ Example πΈ
The source literally says // Run this code, so run this, bestie:
#include <deque>
#include <iostream>
int main()
{
std::deque<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)
mwah π this page is from http://cppreference.com, dated 2024.06.10, and it is the std::deque::pop_front(3) page β periodt, bestie. πβ¨
π¦ 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