basic_string::get_allocator
Zwraca kopię obiektu alokatora używane do skonstruowania ciągu.
allocator_type get_allocator( ) const;
Wartość zwracana
Program przydzielania używane przez ciąg.
Uwagi
Funkcja Członkowskich zwraca obiekt alokatora przechowywane.
Allocators dla klasy string określ, jak klasa zarządza Magazyn.Allocators domyślne dostarczane z kontenera klasy są wystarczające dla potrzeb większości programów.Pisanie i przy użyciu klasy alokatora jest temat zaawansowany C++.
Przykład
// basic_string_get_allocator.cpp
// compile with: /EHsc
#include <string>
#include <iostream>
int main( )
{
using namespace std;
// The following lines declare objects
// that use the default allocator.
string s1;
basic_string <char> s2;
basic_string <char, char_traits< char >, allocator< char > > s3;
// s4 will use the same allocator class as s1
basic_string <char> s4( s1.get_allocator ( ) );
basic_string <char>::allocator_type xchar = s1.get_allocator( );
// You can now call functions on the allocator class xchar used by s1
}
Wymagania
Nagłówek: <string>
Obszar nazw: std