insert_iterator::operator =

값은 컨테이너에 삽입 및 업데이트는 새 요소를 가리키는 반복기를 반환 합니다.

insert_iterator<Container>& operator=(
   typename Container::const_reference _Val,
);
insert_iterator<Container>& operator=(
   typename Container::value_type&& _Val
); 

매개 변수

  • _Val
    컨테이너에 할당 될 값입니다.

반환 값

컨테이너에 삽입할 요소 참조입니다.

설명

첫 번째 멤버 연산자를 계산합니다.

Iter = container->insert(Iter, _Val);

++Iter;

그런 다음 반환 *this.

두 번째 멤버 연산자를 계산합니다.

Iter = container->insert(Iter, std::move(_Val));

++Iter;

그런 다음 반환 *this.

예제

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

int main( )
{
   using namespace std;
   int i;
   list <int>::iterator L_Iter;

   list<int> L;
   for (i = 0 ; i < 4 ; ++i ) 
   {
      L.push_back ( 2 * i );
   }

   cout << "The original list L is:\n ( ";
   for ( L_Iter = L.begin( ) ; L_Iter != L.end( ); L_Iter++ )
      cout << *L_Iter << " ";
   cout << ")." << endl;

   insert_iterator< list < int> > Iter(L, L.begin ( ) );
   *Iter = 10;
   *Iter = 20;
   *Iter = 30;

   cout << "After the insertions, the list L is:\n ( ";
   for ( L_Iter = L.begin( ) ; L_Iter != L.end( ); L_Iter++ )
      cout << *L_Iter << " ";
   cout << ")." << endl;
}
  
  

요구 사항

헤더: <iterator>

네임 스페이스: std

참고 항목

참조

insert_iterator Class

표준 템플릿 라이브러리