Flow
Documentation for the Flow C++ Library
Loading...
Searching...
No Matches
flow_default_memory_resource.h
Go to the documentation of this file.
1#pragma once
3
4namespace flow {
5
9 public:
11 static DefaultMemoryResource instance{};
12 return instance;
13 }
14
15 private:
16 virtual void* allocateImp(std::size_t bytes, std::size_t alignment) {
17 return ::operator new(bytes, static_cast<std::align_val_t>(alignment));
18 }
19
20 virtual void deallocateImp(void* address, [[maybe_unused]] std::size_t bytes, std::size_t alignment) {
21 ::operator delete(address, static_cast<std::align_val_t>(alignment));
22 }
23 };
24}
A default memory resource that wraps global operator new and operator delete.
static DefaultMemoryResource & getResource()
virtual void * allocateImp(std::size_t bytes, std::size_t alignment)
virtual void deallocateImp(void *address, std::size_t bytes, std::size_t alignment)
A memory resource holder interface for the PolymorphicAllocator. Responsible for allocate and dealloc...