다음을 통해 공유


vector::get_allocator

벡터를 만드는 데 사용 되는 할당 기 개체의 복사본을 반환 합니다.

Allocator get_allocator( ) const;

반환 값

사용 하 여 벡터의 할당자입니다.

설명

할당자 벡터 클래스에 대 한 클래스 저장소를 관리 하는 방법을 지정 합니다.STL 컨테이너 클래스를 제공 하는 기본 할당자에 대 한 대부분의 프로그래밍 요구를 충분히 있습니다.작성 한 할당자 클래스를 직접 사용 하는 고급 C++ 항목입니다.

예제

// vector_get_allocator.cpp
// compile with: /EHsc
#include <vector>
#include <iostream>

int main( )
{
   using namespace std;
   // The following lines declare objects that use the default allocator.
   vector<int> v1;
   vector<int, allocator<int> > v2 = vector<int, allocator<int> >(allocator<int>( )) ;

   // v3 will use the same allocator class as v1
   vector <int> v3( v1.get_allocator( ) );

   vector<int>::allocator_type xvec = v3.get_allocator( );
   // You can now call functions on the allocator class used by vec
}

요구 사항

헤더: <vector>

네임 스페이스: std

참고 항목

참조

vector Class

표준 템플릿 라이브러리