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