Allocators make compatibility across otherwise equivalent vectors a nightmare.
All std::pmr::vector are the same type regardless of what kind of std::pmr::memory_resource backs the allocator.
On the other hand std::pmr::polymorphic_allocator only stores a pointer to a std::pmr::memory_resource so normally you store the memory_resource somewhere else with a lifetime longer than the container that uses it.
Making one that behaved as if it was stored inside the container would be slightly tricky, but it's work that would only need to be done once.
11
u/ABlockInTheChain Aug 11 '23
Most of the author's complaints about allocators are valid pre-C++17 but I get the feeling he hasn't used pmr allocators yet.