Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
STL Containers
bitset
deque
list
map
multimap
multiset
priority_queue
queue
set
stack
vector
queue
comparison operators
queue::queue
member functions:
queue::back
queue::empty
queue::front
queue::pop
queue::push
queue::size


queue::pop

public member function
void pop ( );

Delete next element

Removes the next element in the queue, effectively reducing its size by one. The element removed is the "oldest" element in the queue whose value can be retrieved by calling member queue::front.

This calls the removed element's destructor.

This member function effectively calls the member function pop_front of the underlying container object.

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
24
25
26
// queue::push/pop
#include <iostream>
#include <queue>
using namespace std;
int main ()
{
  queue<int> myqueue;
  int myint;
  cout << "Please enter some integers (enter 0 to end):\n";
  do {
    cin >> myint;
    myqueue.push (myint);
  } while (myint);
  cout << "myqueue contains: ";
  while (!myqueue.empty())
  {
    cout << " " << myqueue.front();
    myqueue.pop();
  }
  return 0;
}

The example uses push to add a new elements to the queue, which are then popped out in the same order.

Complexity

Constant.

See also