std::deque::pop_back(3)
πΈ NAME πΈ
okay so bestie, welcome to the C++ Standard Libary manual β yes, that spelling is literally in the header, we are leaving it β and todayβs main character is std::deque::pop_back(3). π
std::deque::pop_back - std::deque::pop_back
β¨ Synopsis β¨
void pop_back();
It removes the last element of the container. Like, the actual last one. No cap. π
Calling pop_back on an empty container results in undefined behavior. do NOT do that, bestie β undefined behavior is not a vibe, itβs a whole glitch era. π
Iterators and references to the erased element are invalidated. The end() iterator is also invalidated. Other references and iterators are not affected. π¦
π Parameters π
(none) β not a single parameter. Empty plate, clean hands. π½οΈ
π Return value π
(none) β it doesnβt hand you anything back. It just does the thing and leaves. π
β Complexity β
Constant. Thatβs it. One little pop, constant energy. β¨
π¦ Exceptions π¦
Throws nothing. Zero exceptions. Unbothered, moisturized, in its lane. π§
π Example π
// Run this code
#include <deque>
#include <iostream>
template<typename T>
void print(T const& xs)
{
std::cout << "[ ";
for (auto const& x : xs)
std::cout << x << ' ';
std::cout << "]\n";
}
int main()
{
std::deque<int> numbers;
print(numbers);
numbers.push_back(5);
numbers.push_back(3);
numbers.push_back(4);
print(numbers);
numbers.pop_back();
print(numbers);
}
π Output π
[ ]
[ 5 3 4 ]
[ 5 3 ]
π See also π
pop_frontremoves the first element β (public member function)push_backadds an element to the end β (public member function)
xoxo, your Unix bestie π β source: http://cppreference.com, version/date: 2024.06.10.
π¦ 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