共用方式為


hash_set::emplace

注意事項注意事項

這個 API 已經過時。這個選項是 unordered_set Class

插入建構的項目就地入 hash_set。

template<class ValTy>
    pair <iterator, bool> emplace(
        ValTy&& _Val
);

參數

參數

描述

_Val

要插入之項目的值至 hash_set Class ,除非 hash_set ,一般而言,已經包含該項目或索引鍵相等的已排序的項目。

傳回值

emplace 成員函式傳回 bool 元件傳回 true 的配對,如果插入是建立和 false ,如果 hash_set 已經包含索引鍵具有等值的順序,因此, Iterator 元件傳回位址或插入新項目的項目已經放置項目。

備註

在 Visual C++ .NET Pocket PC, <hash_map><hash_set> 標頭檔 (Header File) 的成員不在 std 命名空間,,而是移至 stdext 命名空間。 如需詳細資訊,請參閱 stdext 命名空間

範例

// hash_set_emplace.cpp
// compile with: /EHsc
#include <hash_set>
#include <iostream>
#include <string>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_set<string> hs3;
   string str1("a");

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

需求

標題: <hash_set>

命名空間: stdext

請參閱

參考

hash_set Class

標準樣板程式庫