std::pmr — custom allocators for containers.
1#include <memory_resource>23std::pmr::monotonic_buffer_resource pool;4std::pmr::vector<int> v(&pool);56// Fast allocation from pool7for (int i = 0; i < 1000; i++) {8 v.push_back(i); // allocates from pool9}10// All memory freed at once when pool is destroyed
Resources:
monotonic_buffer_resource: fast, no deallocationpool_resource: reusable memory poolnew_delete_resource: default (heap)Benefits: