std::vector::pop_back(3)
π std::vector::pop_back(3) π
okay so welcome to the C++ Standard Libary manual page, bestie β this is the page for std::vector::pop_back.
π NAME π
std::vector::pop_back β std::vector::pop_back
π¦ Synopsis π¦
void pop_back(); (constexpr since C++20)
Removes the last element of the container. <span>β¨</span>
β οΈ Calling pop_back on an empty container results in undefined behavior. no cap, do not do that, bestie π
Iterators (including the end() iterator) and references to the last element are invalidated.
πΈ Parameters πΈ
(none) β literally none, she takes no arguments π
π Return value π
(none) β nothing comes back out, she just does the thing π«Ά
β Complexity β
Constant.
π Exceptions π
Throws nothing.
π§ Example π§
// Run this code
#include <vector>
#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::vector<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 π
push_backβ adds an element to the end (public member function)
mwah π β source: http://cppreference.com, version/date: 2024.06.10, page: std::vector::pop_back(3) β¨
π¦ 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