Export (0) Print
Expand All

deque::push_back

Adds an element to the end of the deque.

void push_back(
   const Type& _Val
);
void push_back(
   Type&& _Val
);

Parameter

Description

_Val

The element added to the end of the deque.

If an exception is thrown, the deque is left unaltered and the exception is rethrown.

// deque_push_back.cpp
// compile with: /EHsc
#include <deque>
#include <iostream>

int main( ) 
{
   using namespace std;
   deque <int> d;
   
   d.push_back( 1 );
   d.push_back( 2 );
   d.push_back( 3 );
   for( deque<int>::const_iterator i = d.begin(); i != d.end(); ++i )
   {
      cout << *i << " ";
   }
   cout << endl;

   d.push_front( 0 );
   d.push_back( 4 );
   for( deque<int>::const_iterator i = d.begin(); i != d.end(); ++i )
   {
      cout << *i << " ";
   }
   cout << endl;

// move initialize a deque of deques by moving d
   deque < deque <int> > dd;

   dd.push_back( move( d ) );
   cout << "Moved last element: " << dd[0].back( ) << endl;
}

1 2 3
0 1 2 3 4
Moved last element: 4

Header: <deque>

Namespace: std

Show:
© 2014 Microsoft