다음을 통해 공유


deque::operator=

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

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

매개 변수

Parameter

설명

_Right

The deque that provides the new content.

설명

The first override copies elements to this deque from _Right, the source of the assignment. The second override moves elements to this deque from _Right.

Elements that are contained in this deque before the operator executes are removed.

예제

// deque_operator_as.cpp
// compile with: /EHsc
#include <deque>
#include <iostream>
using namespace std;

typedef deque<int> MyDeque;

template<typename MyDeque> struct S;

template<typename MyDeque> struct S<MyDeque&> {
  static void show( MyDeque& d ) {
    MyDeque::const_iterator iter;
    for (iter = d.cbegin(); iter != d.cend(); iter++)
       cout << *iter << " ";
    cout << endl;
  }
};

template<typename MyDeque> struct S<MyDeque&&> {
  static void show( MyDeque&& d ) {
    MyDeque::const_iterator iter;
    for (iter = d.cbegin(); iter != d.cend(); iter++)
       cout << *iter << " ";
cout << " via unnamed rvalue reference " << endl;
  }
};

int main( )
{
   MyDeque d1, d2;

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

   cout << "d1 = " ;
   S<MyDeque&>::show( d1 );

   d2 = d1;
   cout << "d2 = ";
   S<MyDeque&>::show( d2 );

   cout << "     ";
   S<MyDeque&&>::show ( move< MyDeque& > (d1) );
 }

Output

d1 = 10 20 30 40 50 
d2 = 10 20 30 40 50 
     10 20 30 40 50 via unnamed rvalue reference

요구 사항

헤더: <deque>

네임스페이스: std

참고 항목

참조

vector 클래스

표준 템플릿 라이브러리