bit::memory
|
A stack-allocation strategy that allocates off of stack-memory. More...
#include <stack_allocator.hpp>
Public Types | |
using | max_alignment = std::integral_constant< std::size_t, Align > |
Public Member Functions | |
stack_allocator () noexcept | |
Default-constructs a stack_allocator. | |
stack_allocator (stack_allocator &&other)=delete | |
stack_allocator (const stack_allocator &other)=delete | |
~stack_allocator () | |
Deallocates all memory from the stack. | |
stack_allocator & | operator= (const stack_allocator &)=delete |
stack_allocator & | operator= (stack_allocator &&other)=delete |
void * | try_allocate (std::size_t size, std::size_t align, std::size_t offset=0) noexcept |
Tries to allocate memory of size size , aligned to the boundary align , offset by offset . More... | |
void | deallocate (void *p, std::size_t size) |
Does nothing for linear_allocator. Use deallocate_all. More... | |
void | deallocate_all () |
Deallocates all memory in this allocator. | |
bool | owns (const void *p) const noexcept |
Checks whether linear_allocator contains the pointer p . More... | |
allocator_info | info () const noexcept |
Gets the info about this allocator. More... | |
A stack-allocation strategy that allocates off of stack-memory.
This offers two different forms of deallocations; either truncated deallocations via deallocate_all, or individual deallocations through deallocate(...) calls. The order of deallocation must be the inverse of the order of construction, otherwise it is undefined behaviour.
Size | The size of the storage in this allocator |
Align | the alignment of the storage |
Definition at line 66 of file stack_allocator.hpp.
void bit::memory::stack_allocator< Size, Align >::deallocate | ( | void * | p, |
std::size_t | size | ||
) |
Does nothing for linear_allocator. Use deallocate_all.
p | the pointer |
size | the size of the allocation |
|
noexcept |
Gets the info about this allocator.
This defaults to 'stack_allocator'. Use a named_stack_allocator to override this
|
noexcept |
Checks whether linear_allocator
contains the pointer p
.
p | the pointer to check |
true
if p
is contained in this allocator
|
noexcept |
Tries to allocate memory of size size
, aligned to the boundary align
, offset by offset
.
size | the size of the allocation |
align | the requested alignment of the allocation |
offset | the amount to offset the alignment by |
nullptr
on failure