Freigeben über


multiset::operator=

Replaces the elements of this multiset using elements from another multiset.

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

Parameters

Parameter

Description

_Right

The multiset from which elements are copied or moved.

Remarks

operator= copies or moves the elements in _Right into this multiset, depending on the reference type (lvalue or rvalue) used. Elements that are in this multiset before operator= executes are discarded.

Example

// multiset_operator_as.cpp
// compile with: /EHsc
#include <multiset>
#include <iostream>

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

Namespace: std

See Also

Reference

multiset Class

Standard Template Library