std::list<T,Allocator>::pop_back
void pop_back(); |
Removes the last element of the container.
| If | (until C++26) |
| If
| (since C++26) |
References and iterators to the erased element are invalidated.
Complexity
Constant.
Example
#include <list>
#include <print>
int main()
{
std::list<int> numbers{1, 2, 3};
for (; not numbers.empty(); numbers.pop_back())
std::println("{}", numbers);
}
Output:
[1, 2, 3] [1, 2] [1]
See also
| removes the first element (public member function) |
|
| adds an element to the end (public member function) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/container/list/pop_back