std::list::pop_back(3)
πΈ NAME πΈ
okay bestie, this is the page for std::list::pop_back(3) from the C++ Standard Libary manual β yes, βLibary,β thatβs the manualβs spelling, not mine π
. The whole NAME line is literally std::list::pop_back β std::list::pop_back, iconic redundancy, we move.
β¨ Synopsis β¨
void pop_back();
She removes the last element of the container. Thatβs the whole job, and she does it.
Calling pop_back on an empty container results in undefined behavior. No cap, do not do this. Thatβs the danger zone π.
References and iterators to the erased element are invalidated. The ones pointing at the erased element, periodt.
π§ Parameters π§
(none) β not a single parameter, bestie.
π Return value π
(none) β she returns nothing, sheβs too busy serving.
π Complexity π
Constant. Chill.
π Exceptions π
Throws nothing. Zero drama, zero throwing.
π¦ Example π¦
The original says // Run this code, so hereβs the code:
// Run this code
#include <list>
#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::list<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)
mwah π this one came from source http://cppreference.com, version/date 2024.06.10, and the footer tag std::list::pop_back(3) β thatβs the whole footer folded into a cute lil sign-off π«Άβ¨
π¦ 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