1// vector::get_allocator
2#include <iostream>
3#include <vector>
4
5int main ()
6{
7 std::vector<int> myvector;
8 int * p;
9 unsigned int i;
10
11 // allocate an array with space for 5 elements using vector's allocator:
12 p = myvector.get_allocator().allocate(5);
13
14 // construct values in-place on the array:
15 for (i=0; i<5; i++) myvector.get_allocator().construct(&p[i],i);
16
17 std::cout << "The allocated array contains:";
18 for (i=0; i<5; i++) std::cout << ' ' << p[i];
19 std::cout << '\n';
20
21 // destroy and deallocate:
22 for (i=0; i<5; i++) myvector.get_allocator().destroy(&p[i]);
23 myvector.get_allocator().deallocate(p,5);
24
25 return 0;
26}