#include <iostream>
#include <list>
namespace ClassFoo{
void ListGetAllocatorExample1(){
std::list<int> foo;
int * p;
// 用内存分配器分配包含5个元素的数组
p = foo.get_allocator().allocate(5);
// 为数组中的每个元素赋值
for (int i = 0; i<5; ++i) p[i] = i;
std::cout << "The allocated array contains:";
for (int i = 0; i<5; ++i) std::cout << ' ' << p[i];
std::cout << '\n';
foo.get_allocator().deallocate(p, 5);
}
}
int main()
{
ClassFoo::ListGetAllocatorExample1();
return 0;
}