Using the Allocator Argument to C++ STL Template Classes

The interface to scalable_allocator and cache_aligned_allocator is identical to std::allocator and conforms to the relevant requirements in the ISO C++ standard, so you can use either as the allocator argument to STL template classes. The following code shows how to declare an STL vector that uses cache_aligned_allocator for allocation:

	std::vector< int, cache_aligned_allocator<int> >;

Get Intel Threading Building Blocks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.