deque - STL C++

deque<X, A>::get_allocator()

Declaration

A deque<X,A>::get_allocator() const;

Description

This is the get_allocator() function for the deque class template.

Header Include

#include <deque>

Example

#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;
}

Output

deque<X, A>::get_allocator() Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.