28 virtual void*
allocateImp(std::size_t bytes, std::size_t alignment)
override {
33 throw std::bad_alloc();
36 new (alignedHeader)
Header(oldBuffer);
37 void* allocatedBlock =
reinterpret_cast<Header*
>(alignedHeader) + 1;
38 buffer_ =
reinterpret_cast<std::byte*
>(allocatedBlock) + bytes;
40 return allocatedBlock;
43 virtual void deallocateImp(
void* address, std::size_t bytes, [[maybe_unused]] std::size_t alignment)
override {
45 assert(address ==
nullptr || address <=
buffer_);
A memory resource holder interface for the PolymorphicAllocator. Responsible for allocate and dealloc...
virtual void * allocateImp(std::size_t bytes, std::size_t alignment) override
virtual void deallocateImp(void *address, std::size_t bytes, std::size_t alignment) override
StackMemoryResource(void *buffer, std::size_t capacity) noexcept
std::size_t pointerDistance(const T *first, const U *last)
Calculate the distance in bytes from the first pointer to the last pointer.
Header * alignWithHeader(std::size_t alignment, std::size_t size, void *&buffer, std::size_t &capacity) noexcept
Align the header + buffer to their corresponding alignments. If the capacity is not big enough,...