list::get_allocator
목록을 생성하는 데 사용되는 할당자 개체의 복사본을 반환합니다.
Allocator get_allocator( ) const;
반환 값
목록에서 사용되는 할당자입니다.
설명
목록 클래스의 할당자는 클래스가 저장소를 관리하는 방법을 지정합니다. STL 컨테이너 클래스와 함께 제공되는 기본 할당자를 사용하면 대부분의 프로그래밍 요구 사항을 충족할 수 있습니다. 할당자 클래스를 직접 작성하고 사용하는 방법에 대해서는 고급 C++ 항목에서 다룹니다.
예제
// list_get_allocator.cpp
// compile with: /EHsc
#include <list>
#include <iostream>
int main( )
{
using namespace std;
// The following lines declare objects
// that use the default allocator.
list <int> c1;
list <int, allocator<int> > c2 = list <int, allocator<int> >( allocator<int>( ) );
// c3 will use the same allocator class as c1
list <int> c3( c1.get_allocator( ) );
list<int>::allocator_type xlst = c1.get_allocator( );
// You can now call functions on the allocator class used by c1
}
요구 사항
헤더: <list>
네임스페이스: std