Partager via


deque::push_front

Adds an element to the beginning of the deque.

void push_front(
   const Type& _Val
);

Parameters

  • _Val
    The element added to the beginning of the deque.

Remarks

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

Example

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

int main( ) 
{
   using namespace std;
   deque <int> c1;
   
   c1.push_front( 1 );
   if ( c1.size( ) != 0 )
      cout << "First element: " << c1.front( ) << endl;

   c1.push_front( 2 );
   if ( c1.size( ) != 0 )
      cout << "New first element: " << c1.front( ) << endl;
}

Output

First element: 1
New first element: 2

Requirements

Header: <deque>

Namespace: std

See Also

Concepts

deque Class

deque Class Members

deque::push_front and deque::pop_front

Standard Template Library