Compartir a través de


unordered_multiset::emplace

Adds an element constructed in place.

template<class ValTy>
    iterator emplace(ValTy&& val);

Parameters

Parameter

Description

ValTy

The in-place constructor argument type.

val

Value to insert.

Remarks

The member function constructs an element X with valand returns the iterator that designates X.

If an exception is thrown during the insertion, the container is left unaltered and the exception is rethrown.

Example 

Code

// std_tr1__unordered_multiset__unordered_multiset_emplace.cpp 
// compile with: /EHsc 
#include <unordered_set> 
#include <iostream>
#include <string> 
 
int main() 
    { 
    unordered_multiset< string> c1;
    string str1("a");

    c1.emplace(move(str1));
    cout << "After the emplace insertion, c1 contains: "
        << *c1.begin() << endl;

     return (0); 
    } 
 

Output

After the emplace insertion, c1 contains: a

Requirements

Header: <unordered_set>

Namespace: std

See Also

Reference

<unordered_set>

unordered_multiset Class

Other Resources

<unordered_set> Members