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
deque
comparison operators
deque::deque
deque::~deque
member functions:
deque::assign
deque::at
deque::back
deque::begin
deque::clear
deque::empty
deque::end
deque::erase
deque::front
deque::get_allocator
deque::insert
deque::max_size
deque::operator=
deque::operator[]
deque::pop_back
deque::pop_front
deque::push_back
deque::push_front
deque::rbegin
deque::rend
deque::resize
deque::size
deque::swap


deque::pop_back

public member function
void pop_back ( );

Delete last element

Removes the last element in the deque container, effectively reducing the container size by one.

This calls the removed element's destructor.

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_back
#include <iostream>
#include <deque>
using namespace std;
int main ()
{
  deque<int> mydeque;
  int sum (0);
  mydeque.push_back (10);
  mydeque.push_back (20);
  mydeque.push_back (30);
  while (!mydeque.empty())
  {
    sum+=mydeque.back();
    mydeque.pop_back();
  }
  cout << "The elements of mydeque summed " << sum << endl;
  return 0;
}

In this example, the elements are popped out from the end of the deque after they are added up in the sum. Output:
The elements of mydeque summed 60

Complexity

Constant.

See also