#include class PageAllocator { public: explicit PageAllocator(std::uint64_t page_size); void* Allocate(); }; 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(...) { p = page_allocator_.Allocate(); } return p; } void Deallocate(Tp* p) { delete p; } const PageAllocator& InnerAllocator() const noexcept { return page_allocator_; } };