다음을 통해 공유


hash_set::operator=

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

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

Parameters

Parameter

Description

_Right

The hash_set Class being copied into the hash_set.

Remarks

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

Example

// hash_set_operator_as.cpp
// compile with: /EHsc
#include <hash_set>
#include <iostream>

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

   v1.insert(10);

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

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

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

Output

v1 = 10 
v2 = 10 
v2 = 10 

Requirements

Header: <hash_set>

Namespace: std

See Also

Reference

hash_set Class

Standard Template Library

Other Resources

hash_set Members