memory
|
A stateful RawAllocator that provides stack-like (LIFO) allocations.
It uses a memory_arena with a given BlockOrRawAllocator
defaulting to growing_block_allocator to allocate huge blocks and saves a marker to the current top. Allocation simply moves this marker by the appropriate number of bytes and returns the pointer at the old marker position, deallocation is not directly supported, only setting the marker to a previously queried position.
Typedefs | |
using | allocator_type = make_block_allocator_t< BlockOrRawAllocator > |
using | marker = implementation_defined |
The marker type that is used for unwinding. | |
Static Functions | |
static constexpr std::size_t | min_block_size (std::size_t byte_size) noexcept |
Member Functions | |
template<typename... Args> | |
memory_stack (std::size_t block_size, Args &&... args) | |
void * | allocate (std::size_t size, std::size_t alignment) |
void * | try_allocate (std::size_t size, std::size_t alignment) noexcept |
marker | top () const noexcept |
void | unwind (marker m) noexcept |
void | shrink_to_fit () noexcept |
std::size_t | capacity_left () const noexcept |
std::size_t | next_capacity () const noexcept |
allocator_type & | get_allocator () noexcept |
using marker = implementation_defined |
The marker type that is used for unwinding.
The exact type is implementation defined, it is only required that it is efficiently copyable and has all the comparision operators defined for two markers on the same stack. Two markers are equal, if they are copies or created from two top()
calls without a call to unwind()
or allocate()
. A marker a
is less than marker b
, if after a
was obtained, there was one or more call to allocate()
and no call to unwind()
.
|
explicit |
block_size
must be at least min_block_size(1)
.
|
staticconstexprnoexcept |
min_block_size(n)
, the resulting capacity will be exactly n
. byte_size
must be a positive number. void * allocate | ( | std::size_t | size, |
std::size_t | alignment | ||
) |
size
is too big. size
and alignment
must be valid.
|
noexcept |
nullptr
if there wasn't enough memory available.
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |