Freigeben über


list::operator=

Ersetzt die Elemente der Liste durch eine Kopie einer anderen Liste.

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

Parameter

Parameter

Description

_Right

list Class, das in list kopiert wird.

Hinweise

Nachdem er einem vorhandenen Elemente in list gelöscht wurde, kopiert der Operator oder verschiebt den Inhalt von _Right in list.

Beispiel

// list_operator_as.cpp
// compile with: /EHsc
#include <list>
#include <iostream>

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

   v1.push_back(10);
   v1.push_back(20);
   v1.push_back(30);
   v1.push_back(40);
   v1.push_back(50);

   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 = forward< list<int> >(v1);
   cout << "v2 = ";
   for (iter = v2.begin(); iter != v2.end(); iter++)
      cout << *iter << " ";
   cout << endl;
}

Output

v1 = 10 20 30 40 50 
v2 = 10 20 30 40 50 
v2 = 10 20 30 40 50 

Anforderungen

Header: <list>

Namespace: std

Siehe auch

Referenz

list Class

Standardvorlagenbibliothek