다음을 통해 공유


list::operator=

요소 목록에 다른 목록의 복사본으로 대체합니다.

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

매개 변수

Parameter

설명

_Right

list Class 에 복사 되는 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;
}

Output

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

요구 사항

헤더: <list>

네임 스페이스: std

참고 항목

참조

list Class

표준 템플릿 라이브러리