1#ifndef included_StackAllocator
2#define included_StackAllocator
22 size_t blockSize = 1024,
23 std::function<
void *(
size_t )> allocator = ::malloc,
24 std::function<
void(
void * )> deallocator = ::free );
45 static constexpr bool isLIFO() {
return true; }
~StackAllocator()
Destructor.
std::function< void *(size_t)> d_allocator
StackAllocator(const StackAllocator &)=delete
StackAllocator(StackAllocator &&)
StackAllocator & operator=(StackAllocator &&)
StackAllocator(size_t bytes, size_t blockSize=1024, std::function< void *(size_t)> allocator=::malloc, std::function< void(void *)> deallocator=::free)
Default constructor.
StackAllocator & operator=(const StackAllocator &)=delete
StackAllocator()
Empty constructor.
void deallocate(void *p, size_t bytes)
Deallocate memory.
std::function< void(void *)> d_deallocator
static constexpr bool isLIFO()
Check if the allocator is Last-In-First-Out (LIFO)
void * allocate(size_t bytes)
Allocate memory.