다음을 통해 공유


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 클래스

표준 템플릿 라이브러리