hash_map::operator=

注意事項注意事項

這個 API 已經過時。這個選項是 unordered_map Class

用另一個 hash_map 的複本來取代 hash_map 的項目。

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

參數

參數

描述

_Right

複製到的 hash_maphash_map Class

備註

在清除在 hash_map的任何現有項目之後, operator= 複製或移動 _Right 內容 hash_map。

範例

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

Output

v1 = 10 
v2 = 10 
v2 = 10 

需求

標題: <hash_map>

命名空間: std

請參閱

參考

hash_map Class

標準樣板程式庫