![]() |
---|
此 API 已过时。另一种方法是 unordered_multimap Class。 |
插入构造的元素就地到 hash_multimap 中。
template<class ValTy>
iterator emplace(
ValTy&& _Val
);
参数
Parameter |
描述 |
_Val |
用于的值将构造要插入的元素。hash_multimap Class。 |
返回值
emplace 成员函数返回指向位置插入新元素的迭代器。
备注
元素的 hash_multimap::value_type 是对,因此,元素的值将排序的匹配的第一个元素等于键值和第二个元素为等于元素的数据值。
从 Visual C++ .NET 2003 中启动,<hash_map> 和 <hash_set> 标头文件的成员中不再标准,命名空间,而是将 stdext 命名空间。有关更多信息,请参见 stdext 命名空间。
示例
// hash_multimap_emplace.cpp
// compile with: /EHsc
#include<hash_multimap>
#include<iostream>
#include <string>
int main()
{
using namespace std;
using namespace stdext;
hash_multimap<int, string> hm1;
typedef pair<int, string> is1(1, "a");
hm1.emplace(move(is1));
cout << "After the emplace, hm1 contains:" << endl
<< " " << hm1.begin()->first
<< " => " << hm1.begin()->second
<< endl;
}
要求
标头: <hash_map>
命名空间: stdext