list::get_allocator
Gibt eine Kopie des Zuweisungsobjekts zurück, das zum Erstellen einer Liste verwendet wird.
Allocator get_allocator( ) const;
Rückgabewert
Die Zuweisung von der Liste verwendet.
Hinweise
Zuweisungen für die Listenklasse geben an, wie die Klasse einen Speicher verwaltet. Für die meisten Programmieranforderungen reichen die Standard-Zuweisungen mit STL-Container-Klassen aus. Schreiben und Verwenden Ihrer eigener Zuweisungsklasse ist ein C++ -Thema für Fortgeschrittene.
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