libstdc++: Polymorphic memory resources (original) (raw)

Memory resources are classes that implement the std::pmr::memory_resource interface for allocating and deallocating memory. Unlike traditional C++ allocators, memory resources are not value types and are used via pointers to the abstract base class. They are only responsible for allocating and deallocating, not for construction and destruction of objects. As a result, memory resources just allocate raw memory as type void* and are not templates that allocate/deallocate and construct/destroy a specific type.

The class template std::pmr::polymorphic_allocator is an allocator that uses a memory resource for its allocations.