Windows Dev Center

Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

list::emplace

Inserts an element constructed in place into a list at a specified position.

void emplace_back( 
   iterator _Where, 
   Type&& _Val 
);

Parameter

Description

_Where

The position in the target list Class where the first element is inserted.

_Val

The element added to the end of the list.

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

// list_emplace.cpp
// compile with: /EHsc
#include <list>
#include <iostream>
#include <string>

int main( ) 
{
   using namespace std;
   list <string> c2;
   string str("a");

   c2.emplace(c2.begin(), move( str ) );
   cout << "Moved first element: " << c2.back( ) << endl;
}
Moved first element: a

Header: <list>

Namespace: std

Show:
© 2015 Microsoft