Freigeben über


hash_map::operator=

Hinweis

Diese API ist veraltet.Die Alternative ist unordered_map-Klasse.

Ersetzt die Elemente des hash_map durch eine Kopie eines anderen hash_map.

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

Parameter

Parameter

Beschreibung

_Right

hash_map-Klasse, das in hash_map kopiert wird.

Hinweise

Nachdem es dabei vorhandenen Elemente in hash_map gelöscht hat, kopiert operator= entweder oder verschieben Sie den Inhalt von _Right in hash_map.

Beispiel

// hash_map_operator_as.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_map<int, int> v1, v2, v3;
   hash_map<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;
}

Ausgabe

v1 = 10 
v2 = 10 
v2 = 10 

Anforderungen

Header: <hash_map>

Namespace: std

Siehe auch

Referenz

hash_map-Klasse

Standardvorlagenbibliothek