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