bit::memory
|
This allocator acts as an aggregate that can fall back to other allocators on failure. More...
#include <fallback_allocator.hpp>
Public Member Functions | |
fallback_allocator (AllocatorStorages...storages) noexcept | |
Constructs each allocator in the fallback_allocator in-place, constructing each allocator from a single argument. More... | |
fallback_allocator (fallback_allocator &&other)=default | |
Move-constructs the fallback_allocator from an existing one. More... | |
fallback_allocator (const fallback_allocator &other)=default | |
Copy-constructs the fallback_allocator from an existing one. More... | |
fallback_allocator & | operator= (fallback_allocator &&other)=default |
Move-assigns the fallback_allocator from an existing one. More... | |
fallback_allocator & | operator= (const fallback_allocator &other)=default |
Copy-assigns the fallback_allocator from an existing one. More... | |
owner< void * > | try_allocate (std::size_t size, std::size_t align) noexcept |
Attempts to allocate memory, starting with the first allocator in sequence, and falling back to further allocators on failure. More... | |
void | deallocate (owner< void *> p, std::size_t size) |
Deallocates the pointer p of size size from the underlying allocator. More... | |
bool | owns (const void *p) const noexcept |
Checks if any of the allocators in the fallback allocator owns the memory pointer to by p . More... | |
std::size_t | max_size () const noexcept |
Determines the maximum size of the allocations that this fallback_allocator supports. More... | |
std::size_t | min_size () const noexcept |
Determines the minimum size of the allocations that this fallback_allocator supports. More... | |
This allocator acts as an aggregate that can fall back to other allocators on failure.
This will attempt to allocate memory from the first allocator in the sequence, and – on failure – will fall-back to the next one in sequence.
For deallocations, all allocators except the last one must implement the 'owns' member function to identify ownership of previously allocated memory. The last allocator in the sequence is a special-case that doesn't require ownership, allowing for raw allocators to be used as the final fallback in the allocation sequence.
AllocatorStorages | the allocator storages to sequence through |
Definition at line 73 of file fallback_allocator.hpp.
|
explicitnoexcept |
Constructs each allocator in the fallback_allocator in-place, constructing each allocator from a single argument.
storages | the allocator storage types to use |
|
default |
Move-constructs the fallback_allocator from an existing one.
other | the other fallback_allocator to move |
|
default |
Copy-constructs the fallback_allocator from an existing one.
other | the other fallback_allocator to copy |
void bit::memory::fallback_allocator< AllocatorStorages >::deallocate | ( | owner< void *> | p, |
std::size_t | size | ||
) |
Deallocates the pointer p
of size size
from the underlying allocator.
p
may be incorrectly determined and deallocated incorrectly.p | the pointer to memory to deallocate |
size | the size of the memory to deallocate |
|
noexcept |
Determines the maximum size of the allocations that this fallback_allocator supports.
|
noexcept |
Determines the minimum size of the allocations that this fallback_allocator supports.
|
default |
Move-assigns the fallback_allocator from an existing one.
other | the other fallback_allocator to move |
|
default |
Copy-assigns the fallback_allocator from an existing one.
other | the other fallback_allocator to copy |
|
noexcept |
Checks if any of the allocators in the fallback allocator owns the memory pointer to by p
.
p | the pointer to check |
true
if the memory is owned by an allocator in this allocator
|
noexcept |
Attempts to allocate memory, starting with the first allocator in sequence, and falling back to further allocators on failure.
size | the size of the allocation request |
align | the alignment of the allocation request |
nullptr
on failure