public member function
<deque>

std::deque::pop_front

void pop_front();
Delete first element
Removes the first element in the deque container, effectively reducing its size by one.

This destroys the removed element.

Parameters

none

Return value

none

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// deque::pop_front
#include <iostream>
#include <deque>

int main ()
{
  std::deque<int> mydeque;

  mydeque.push_back (100);
  mydeque.push_back (200);
  mydeque.push_back (300);

  std::cout << "Popping out the elements in mydeque:";
  while (!mydeque.empty())
  {
    std::cout << ' ' << mydeque.front();
    mydeque.pop_front();
  }

  std::cout << "\nThe final size of mydeque is " << int(mydeque.size()) << '\n';

  return 0;
}

Output:
Popping out the elements in mydeque: 100 200 300
The final size of mydeque is 0

Complexity

Constant.

Iterator validity

The iterators, pointers and references referring to the removed element are invalidated.
Iterators, pointers and references referring to other elements that have not been removed are guaranteed to keep referring to the same elements they were referring to before the call.

Data races

The container is modified.
The first element is modified. Concurrently accessing or modifying other elements is safe (although see iterator validity above).

Exception safety

If the container is not empty, the function never throws exceptions (no-throw guarantee).
Otherwise, the behavior is undefined.

See also