Share via


list::get_allocator

リストの構築に使用されるアロケーター オブジェクトのコピーを返します。

Allocator get_allocator( ) const;

戻り値

リストで使用されるアロケーター。

解説

list クラスのアロケーターは、クラスがどのようにストレージを管理するかを指定します。 STL コンテナー クラスで提供される既定のアロケーターは、ほとんどのプログラミング要件に対応しています。 独自のアロケーター クラスを作成して使用することは、C++ における高度な作業の 1 つです。

使用例

// 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

参照

関連項目

list クラス

標準テンプレート ライブラリ