Chapter 19. Allocators
Allocators, introduced in Section 4.6, page 57, represent a special memory model and are an abstraction used to translate the need to use memory into a raw call for memory. This chapter describes allocators and corresponding low-level features to deal with memory. Details are provided in a supplementary section of the book, available at the book’s Web site: http://www.cppstdlib.com.
19.1. Using Allocators as an Application Programmer
For the application programmer, using different allocators should be no problem. You simply have to pass the allocator as a template argument. For example, the following statements create different containers and strings, using the special allocator MyAlloc<>
:
Get C++ Standard Library, The: A Tutorial and Reference, 2nd Edition 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.