次の方法で共有


hash_map::operator=

[!メモ]

この API は、互換性のために残されています。代わりに unordered_map クラスです。

別のhash_mapのコピーとhash_mapの要素を置き換えます。

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

パラメーター

パラメーター

説明

_Right

hash_map Class 内にコピーされる hash_map Class

解説

hash_mapに hash_map、operator= のコピーまたは移動を既存の要素をすべて削除した後、の内容の _Right

使用例

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

出力

v1 = 10 
v2 = 10 
v2 = 10 

必要条件

ヘッダー: <hash_map>

名前空間: std

参照

関連項目

hash_map Class

標準テンプレート ライブラリ