다음을 통해 공유


list::operator=

목록의 요소를 다른 목록의 복사본으로 바꿉니다.

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

매개 변수

매개 변수

설명

_Right

list에 복사되는 list 클래스입니다.

설명

연산자는 list에서 기존 요소를 지운 후에 _Right의 내용을 list로 복사하거나 이동합니다.

예제

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

출력

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

요구 사항

헤더: <list>

네임스페이스: std

참고 항목

참조

list 클래스

표준 템플릿 라이브러리