A deque<X,A>::get_allocator() const;
#include <deque>
#include <iostream> #include <deque> int main() { using namespace std; // Create a deque instance and get the allocator deque<int> qD; deque<int>::allocator_type qAlloc = qD.get_allocator(); // Use the allocator to allocate an array of three ints allocator<int>::pointer qPtr = qAlloc.allocate(3); qPtr[0] = 8; qPtr[1] = 4; qPtr[2] = 2; // Output the three ints in the allocated array for (int iIndex = 0; iIndex < 3; ++iIndex) { cout << qPtr[iIndex] << " "; } cout << endl; // Deallocate the memory qAlloc.destroy(qPtr); // Keep the window open cin.get(); return 0; }
© 20072024 XoaX.net LLC. All rights reserved.