An Allocator is a Handle to a Heap
summary
Claim: an allocator is not a heap but a cheap handle to a heap: std::pmr::polymorphic_allocator holds a pointer to a std::pmr::memory_resource and copying the allocator copies the handle not the memory. Demonstrated failure of an allocator-that-contains-its-own-buffer (dangling pointers), the working model using std::pmr::polymorphic_allocator and memory_resource, and consequences: allocators must be rebindable family, cheaply copyable, move-from must preserve value. Notable specifics: stateless std::allocator uses zero-bit stateless allocator semantics; one‑byte indexing hack for small resource tables is possible.
AI-written summary · about
chapters (17)
- 0:00Intro
- 1:03Outline
- 1:31What is an object?
- 5:49What is a (sequence) container?
- 7:14What is an allocator?
- 8:51What goes into an allocator?
- 10:58std::pmr:: polymorphic_allocator
- 19:00Standard new_delete_resource()
- 27:03Corollaries to the new way of thinking
- 28:17Allocators must be "copy-only" types
- 34:13Allocators are "rebindable family" types
- 43:30Allocator source of memory
- 44:57Container uses pointer for all allocations
- 46:31Fancy pointers' range = raw pointers' range
- 47:05So are fancy pointers just native pointers?
- 50:39A C++ allocator is...
- 57:49Truly polymorphic allocator
related talks
57m“An allocator model for std2”
01h 02mPractical Memory Pool Based Allocators For Modern C++
01h 12mstd::allocator...
01h 01mWhat Programmers Should Know About Memory Allocation
01h 23mRethink Polymorphism in C++
27mHow to Hold a T
33mResource polymorphism: proposal for integrating first-class resources into ML
01h 11mI just wanted to point to something!
