hash_set::emplace

说明说明

此 API 已过时。另一种方法是 unordered_set Class

插入构造的元素就地到 hash_set 中。

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

参数

Parameter

描述

_Val

要插入的元素的值设置为 hash_set Class,除非 hash_set,通常,已包含该元素或键相同地排序的元素。

返回值

emplace 成员函数返回 bool 组件返回 true 的对,如果插入是使和 false,如果 hash_set 已经包含一个键具有等效值顺序,并且,迭代器元素返回地址插入或新元素的元素已找到其中的元素。

备注

在 Visual C++ .NET 2003 中,<hash_map><hash_set> 标头文件的成员中不再标准,命名空间,而是将 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

标准模板库