Allocator-Aware C++ Type Design
summary
Adds allocator support to a simple DynamicOptional as a worked reference implementation: allocator becomes a second template parameter defaulting to std::allocator<T>, constructors accept std::allocator_arg_t overloads, and code uses allocator_traits (pointer typedef, allocate/construct/destroy/deallocate) plus select_on_container_copy_construction and the propagate_on_container_* traits to decide copy/move/swap behavior. Tests expose finicky edge cases—especially that swap is undefined if allocators don’t compare equal—so helpers for construct/destroy and careful allocator propagation are required for correct, portable behavior.
AI-written summary · about
chapters (6)
- 0:00Introduction and motivation
- 2:44Implementing dyn_optional
- 6:16Understanding allocators
- 11:30Lego analogy for allocators
- 15:07Adding allocator support
- 31:52Closing and acknowledgments
related talks
01h 04mHow to Write a Custom Allocator
01h 01mGetting Allocators out of Our Way
01h 31mAllocator-Aware (AA) Software
57m“An allocator model for std2”
01h 01mAllocators: The Good Parts
01h 25mTaming Dynamic Memory - An Introduction to Custom Allocators
01h 02mFancy Pointers for Fun and Profit
01h 21mMany an `any`
