std::deque<T,Allocator>::pop_back
void pop_back(); |
Removes the last element of the container.
| If | (until C++26) |
| If
| (since C++26) |
Iterators and references to the last element are invalidated. The end() iterator is also invalidated.
Complexity
Constant.
Example
#include <deque>
#include <print>
int main()
{
std::deque<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/deque/pop_back