共用方式為


unordered_set::emplace_hint

新增項目建構中的位置。

template<class ValTy>
    iterator emplace_hint(const_iterator where, ValTy&& val);

參數

參數

描述

ValTy

在就地的建構函式的引數型別。

val

若要插入的值。

where

若要插入 (只有提示) 的容器中的位置。

備註

成員函式會傳回insert(move(val)).first、 使用where為起始的位置中搜尋插入點的受控制序列。 (插入可能可能速度會較快,如果插入點立即前面或後面是where。)

如果在插入動作期間擲回例外狀況時,就會留在容器不變,和例外狀況重新擲回。

範例 

Dd779103.collapse_all(zh-tw,VS.110).gif程式碼

// std_tr1__unordered_set__unordered_set_emplace_hint.cpp 
// compile with: /EHsc 
#include <unordered_set> 
#include <iostream>
#include <string> 
 
    unordered_set< string> c1;
    string str1("a");

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

Dd779103.collapse_all(zh-tw,VS.110).gifOutput

After the emplace insertion, c1 contains: a

需求

標頭: <unordered_set>

Namespace: 標準

請參閱

參考

<unordered_set>

unordered_set Class

其他資源

<unordered_set> 成員