How to Write a Custom Allocator
summary
Explains how to implement C++14/17 allocators by showing the exact plumbing: required member functions (value_type, allocate, deallocate, converting ctor), how allocator_traits and pointer_traits synthesize missing types, and when containers call select_on_container_copy_construction or rely on polymorphic memory_resource. Covers synthetic pointers for shared memory, PMR-derived resources like monotonic_buffer_resource, propagation flags (propagate_on_move_assign, is_always_equal) and why PMR is usually the simpler starting point.
AI-written summary · about
chapters (12)
- 0:00Introduction to custom allocators
- 1:05What is an allocator?
- 6:24Why write a custom allocator?
- 12:25History of allocators
- 18:32Modern allocator facilities
- 27:18Allocator traits explained
- 36:59Pointer traits and fancy pointers
- 43:55Minimal allocator interface
- 46:51Polymorphic memory resources
- 52:10Writing allocator-aware containers
- 58:20Guidelines for allocator design
- 1:01:40Summary and Q&A
related talks
01h 25mTaming Dynamic Memory - An Introduction to Custom Allocators
01h 01mGetting Allocators out of Our Way
34mAllocator-Aware C++ Type Design
49mMost Malleable Memory Management Method in C++
01h 03mMost Malleable Memory Management Method
01h 01mRecipes for Reducing Allocations by C++ Containers
04mAn allocator is a handle to a heap
01h 02mFancy Pointers for Fun and Profit
