hash_multimap::operator=

说明说明

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

用另一 hash_multimap 的副本替换 hash_multimap 的元素。

hash_multimap& operator=(
   const hash_multimap& _Right
);
hash_multimap& operator=(
   hash_multimap&& _Right
);

参数

Parameter

描述

_Right

复制到 hash_multimap的 hash_multimap Class

备注

在清除在 hash_multimap的任何现有组件后,operator= 复制或移动 _Right 内容 hash_multimap。

示例

// hash_multimap_operator_as.cpp
// compile with: /EHsc
#include <hash_multimap>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multimap<int, int> v1, v2, v3;
   hash_multimap<int, int>::iterator iter;

   v1.insert(pair<int, int>(1, 10));

   cout << "v1 = " ;
   for (iter = v1.begin(); iter != v1.end(); iter++)
      cout << iter->second << " ";
   cout << endl;

   v2 = v1;
   cout << "v2 = ";
   for (iter = v2.begin(); iter != v2.end(); iter++)
      cout << iter->second << " ";
   cout << endl;

// move v1 into v2
   v2.clear();
   v2 = move(v1);
   cout << "v2 = ";
   for (iter = v2.begin(); iter != v2.end(); iter++)
      cout << iter->second << " ";
   cout << endl;
}

Output

v1 = 10 
v2 = 10 
v2 = 10 

要求

标头: <hash_map>

命名空间: std

请参见

参考

hash_multimap Class

标准模板库