Przejdź do głównej zawartości

std::deque pop_back() method

// Non const version only
void pop_back();

Removes the first element of the container.

Undefined Behavior

Calling pop_front on an empty container results in undefined behavior

.

Invalidation

Iterators and references to the erased element are invalidated.
The past-the-end iterator is also invalidated.
Other references and iterators are not affected.

Parameters

(none)

Return value

(none)

Complexity

Constant - O(1).

Exceptions

(none)

Example

Main.cpp
#include <deque>
#include <iostream>

int main()
{
std::deque<char> chars{'A', 'B', 'C', 'D'};

for (; !chars.empty(); chars.pop_front())
{
std::cout << "chars.front(): '" << chars.front() << "'\n";
}
}
Output
chars.front(): 'A'
chars.front(): 'B'
chars.front(): 'C'
chars.front(): 'D'
This article originates from this CppReference page. It was likely altered for improvements or editors' preference. Click "Edit this page" to see all changes made to this document.
Hover to see the original license.

std::deque pop_back() method

// Non const version only
void pop_back();

Removes the first element of the container.

Undefined Behavior

Calling pop_front on an empty container results in undefined behavior

.

Invalidation

Iterators and references to the erased element are invalidated.
The past-the-end iterator is also invalidated.
Other references and iterators are not affected.

Parameters

(none)

Return value

(none)

Complexity

Constant - O(1).

Exceptions

(none)

Example

Main.cpp
#include <deque>
#include <iostream>

int main()
{
std::deque<char> chars{'A', 'B', 'C', 'D'};

for (; !chars.empty(); chars.pop_front())
{
std::cout << "chars.front(): '" << chars.front() << "'\n";
}
}
Output
chars.front(): 'A'
chars.front(): 'B'
chars.front(): 'C'
chars.front(): 'D'
This article originates from this CppReference page. It was likely altered for improvements or editors' preference. Click "Edit this page" to see all changes made to this document.
Hover to see the original license.