#include template class FixedAllocator { PageAllocator page_allocator_; std::uint64_t page_size; public: explicit FixedAllocator(std::uint64_t page_size) : page_size(page_size) {} ~FixedAllocator() { delete page_allocator_; } Tp* Allocate() { Tp* p; try { p = new(sizeof(Tp) * page_size); } catch(...) { page_allocator_ = new PageAllocator(page_size); p = reinterpret_cast(page_allocator_.Allocate()); } return p; } void Deallocate(Tp* p) { delete p; } const PageAllocator& InnerAllocator() const noexcept { return page_allocator_; } };