Share via


hash_multimap::operator=

Note

This API is obsolete. The alternative is unordered_multimap Class.

Replaces the elements of the hash_multimap with a copy of another hash_multimap.

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

Parameters

Parameter

Description

_Right

The hash_multimap Class being copied into the hash_multimap.

Remarks

After erasing any existing elements in a hash_multimap, operator= either copies or moves the contents of _Right into the hash_multimap.

Example

// 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 

Requirements

Header: <hash_map>

Namespace: std

See Also

Reference

hash_multimap Class

Standard Template Library