unordered_multimap::emplace_hint

新增項目建構中的位置。

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

參數

參數

描述

ValTy

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

val

若要插入的值。

where

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

備註

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

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

範例

// std_tr1__unordered_multimap__unordered_multimap_emplace_hint.cpp 
// compile with: /EHsc 
#include <unordered_map> 
#include <iostream> 
#include <string>
 
typedef std::unordered_multimap<char, int> Mymap; 
int main() 
    { 
    using namespace std;
    unordered_multimap<int, string> c1;
    pair<int, string> is1(1, "a");

    c1.emplace(move(is1));
    cout << "After the emplace insertion, c1 contains:" << endl
      << " " << c1.begin()->first
      << " => " << c1.begin()->second
      << endl;
 
    return (0); 
    } 
 
  

需求

標頭: <unordered_multimap>

Namespace: 標準

請參閱

參考

<unordered_map>

unordered_map Class

其他資源

<unordered_map> 成員