![]() |
Allocators
|
Allocates with secondary allocator, if allocation with primary allocator fails. More...
#include <fallback_allocator.hpp>
Public Member Functions | |
memory_block | allocate (std::size_t size) |
Allocates a memory_block with either primary_allocator or secondary_allocator. More... | |
void | deallocate (memory_block &block) |
Deallocates the given memory_block. More... | |
bool | owns (memory_block &block) |
Examines if the given block is owned by this allocator. More... | |
primary_allocator & | get_primary () noexcept |
secondary_allocator & | get_secondary () noexcept |
Allocates with secondary allocator, if allocation with primary allocator fails.
This type of allocator allows construction of allocator chains, where allocation is automatically passed over to the secondary allocator in event the primary allocation cannot succeed due to conditions imposed on the allocator.
primary_allocator | The primary allocator type to be used. |
secondary_allocator | The secondary allocator type to be used. |
Definition at line 27 of file fallback_allocator.hpp.
|
inline |
Allocates a memory_block with either primary_allocator or secondary_allocator.
size | Desired size of the newly allocated block. |
Definition at line 13 of file fallback_allocator.ipp.
|
inline |
Deallocates the given memory_block.
The given memory_block is only deallocated if it's owned by either of the backing allocators and should be handled for deallocation to an instance of that allocator.
block | The memory_block to deallocate. |
Definition at line 23 of file fallback_allocator.ipp.
|
inline |
Examines if the given block is owned by this allocator.
A memory_block is owned by a fallback allocator only if it's owned by either of the backing allocators.
block | A memory_block to examine. |
Definition at line 32 of file fallback_allocator.ipp.