deque::emplace_back

Adds an element constructed in place to the end of the deque.

void emplace_back(
   Type&&_Val
);

Parameters

Parameter

Description

_Val

The element added to the end of the deque Class.

Example

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

int main( )
{
   using namespace std;   
   deque <int> v1;
   
   v1.push_back( 1 );
   if ( v1.size( ) != 0 )
      cout << "Last element: " << v1.back( ) << endl;

   v1.push_back( 2 );
   if ( v1.size( ) != 0 )
      cout << "New last element: " << v1.back( ) << endl;

// initialize a deque of deques by moving v1
   deque < deque <int> > vv1;

   vv1.emplace_back( move( v1 ) );
   if ( vv1.size( ) != 0 && vv1[0].size( ) != 0 )
      cout << "Moved last element: " << vv1[0].back( ) << endl;
}
Last element: 1
New last element: 2
Moved last element: 2

Requirements

Header: <deque>

Namespace: std

See Also

Reference

deque Class

Standard Template Library