다음을 통해 공유


list::list

요소를 특정 값 또는 특정 할당자는 또는 모든 복사본 또는 일부 다른 목록 또는 특정 크기의 목록을 만듭니다.

list( );
explicit list(
   const Allocator& _Al
);
explicit list(
   size_type _Count
);
list(
   size_type _Count,
   const Type& _Val
);
list(
   size_type _Count,
   const Type& _Val,
   const Allocator& _Al
);
list(
   const list& _Right
);
template<class InputIterator>
   list(
      InputIterator _First,
      InputIterator _Last
   );
template<class InputIterator >
   list(
      InputIterator _First,
      InputIterator _Last,
      const Allocator& _Al
   );
list(
   list&& _Right
);

매개 변수

Parameter

설명

_Al

이 개체에 사용할 할당자 클래스입니다.

_Count

목록 구성 요소의 수입니다.

_Val

구성 목록에 있는 요소의 값입니다.

_Right

목록 중 복사본으로 구성 된 목록입니다.

_First

복사할 요소의 범위에 있는 첫 번째 요소의 위치입니다.

_Last

복사할 요소의 범위를 벗어나는 첫 번째 요소의 위치입니다.

설명

모든 생성자는 할당 기 개체 저장 (_Al) 및 목록 초기화 합니다.

get_allocator 목록을 만드는 데 사용 되는 할당 기 개체의 복사본을 반환 합니다.

빈 초기 목록, 두 번째는 처음 두 명의 생성자를 지정 할당자 형식을 지정 (_Al) 사용할 수 있습니다.

세 번째 생성자는 지정된 된 숫자의 반복을 지정 (_Count) 요소의 클래스에 대 한 기본값은 유형.

네 번째 및 다섯 번째 생성자는 반복 횟수 지정 (_Count) 요소 값의 _Val.

여섯 번째 생성자 목록의 사본을 지정 _Right.

범위는 다음 두 생성자 복사 [_First, _Last)의 목록입니다.

마지막 생성자는 목록 이동 _Right.

생성자의 모든 중간 재할당을 수행합니다.

예제

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

int main( ) 
{
   using namespace std;
   list <int>::iterator c1_Iter, c2_Iter, c3_Iter, c4_Iter, c5_Iter, c6_Iter, c7_Iter;

   // Create an empty list c0
   list <int> c0;

   // Create a list c1 with 3 elements of default value 0
   list <int> c1( 3 );

   // Create a list c2 with 5 elements of value 2
   list <int> c2( 5, 2 );

   // Create a list c3 with 3 elements of value 1 and with the 
   // allocator of list c2
   list <int> c3( 3, 1, c2.get_allocator( ) );

   // Create a copy, list c4, of list c2
   list <int> c4(c2);

   // Create a list c5 by copying the range c4[_First, _Last)
   c4_Iter = c4.begin( );
   c4_Iter++;
   c4_Iter++;
   list <int> c5( c4.begin( ), c4_Iter );

   // Create a list c6 by copying the range c4[_First, _Last) and with 
   // the allocator of list c2
   c4_Iter = c4.begin( );
   c4_Iter++;
   c4_Iter++;
   c4_Iter++;
   list <int> c6( c4.begin( ), c4_Iter, c2.get_allocator( ) );

   cout << "c1 =";
   for ( c1_Iter = c1.begin( ); c1_Iter != c1.end( ); c1_Iter++ )
      cout << " " << *c1_Iter;
   cout << endl;
   
   cout << "c2 =";
   for ( c2_Iter = c2.begin( ); c2_Iter != c2.end( ); c2_Iter++ )
      cout << " " << *c2_Iter;
   cout << endl;

   cout << "c3 =";
   for ( c3_Iter = c3.begin( ); c3_Iter != c3.end( ); c3_Iter++ )
      cout << " " << *c3_Iter;
   cout << endl;

   cout << "c4 =";
   for ( c4_Iter = c4.begin( ); c4_Iter != c4.end( ); c4_Iter++ )
      cout << " " << *c4_Iter;
   cout << endl;

   cout << "c5 =";
   for ( c5_Iter = c5.begin( ); c5_Iter != c5.end( ); c5_Iter++ )
      cout << " " << *c5_Iter;
   cout << endl;

   cout << "c6 =";
   for ( c6_Iter = c6.begin( ); c6_Iter != c6.end( ); c6_Iter++ )
      cout << " " << *c6_Iter;
   cout << endl;

   // Move list c6 to list c7
   list <int> c7( move(c6) );
   list <int>::iterator c7_Iter,
   
   cout << "c7 =" ;
   for ( c7_Iter = c7.begin( ) ; c7_Iter != c7.end( ) ; c7_Iter++ )
      cout << " " << *c7_Iter;
   cout << endl;
}
  

요구 사항

헤더: <list>

네임 스페이스: std

참고 항목

참조

list Class

list::list (STL Samples)

표준 템플릿 라이브러리