Freigeben über


list::get_allocator

Gibt eine Kopie des allocator-Objekts zurück, das verwendet wird, um eine Liste zu erstellen.

Allocator get_allocator( ) const;

Rückgabewert

Die Belegungsfunktion verwendet durch die Liste.

Hinweise

Belegungsfunktionen für die Listenklasse geben an, wie die Klasse Speicher verwaltet.Die standardmäßige Belegungsfunktionen, die mit STL-Containerklassen angegeben werden, sind für die meisten Programmierung Anforderungen genügen.Ihre eigene allocator-Klasse zu schreiben und die Anwendung ist ein erweitertes C++-Thema.

Beispiel

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

Anforderungen

Header: <list>

Namespace: std

Siehe auch

Referenz

list Class

Standardvorlagenbibliothek