A non-owning allocator type that type-erases an underlying allocator.
More...
#include <allocator_reference.hpp>
|
using | default_alignment = std::integral_constant< std::size_t, 1 > |
|
A non-owning allocator type that type-erases an underlying allocator.
This view is non-owning, and thus does not participate in the lifetime of a given allocator.
- Note
- Since this is type-erased, any static information – such as
is_stateless
, etc – is lost. It is NOT intended as a drop-in replacement for allocators; only a means of type-erasing the allocator so that underlying APIs need-not require the type of allocator embedded in the class.
- Satisfies
- Allocator
Definition at line 70 of file allocator_reference.hpp.
◆ allocator_reference() [1/3]
template<typename Allocator , typename = std::enable_if_t<is_allocator<std::decay_t<Allocator>>::value && !std::is_same<allocator_reference,std::decay_t<Allocator>>::value>>
bit::memory::allocator_reference::allocator_reference |
( |
Allocator & |
allocator | ) |
|
|
noexcept |
Constructs an allocator by type erasing the underlying allocator.
- Parameters
-
allocator | the allocator to type-erase |
◆ allocator_reference() [2/3]
Copy-constructs an allocator from an existing one.
- Parameters
-
other | the other allocator to copy |
◆ allocator_reference() [3/3]
Move-constructs an allocator from an existing one.
- Parameters
-
other | the other allocator to move |
◆ allocate()
owner<void*> bit::memory::allocator_reference::allocate |
( |
std::size_t |
size, |
|
|
std::size_t |
align |
|
) |
| |
Allocates a block from the underlying block allocator.
- Parameters
-
size | the size of the allocation |
align | the alignment of the allocation |
- Returns
- the allocated pointer
◆ deallocate()
void bit::memory::allocator_reference::deallocate |
( |
owner< void *> |
p, |
|
|
std::size_t |
n |
|
) |
| |
Deallocates a block from the underlying block allocatore.
- Parameters
-
p | the entry to deallocate, originally allocated with a call to allocate |
n | the number of entries to destroy |
◆ info()
Gets the amount of bytes used for this allocator.
- Returns
- the amount of bytes used
◆ operator=() [1/2]
Copy-assigns an allocator from an existing one.
- Parameters
-
other | the other allocator to copy |
- Returns
- reference to
(*this)
◆ operator=() [2/2]
Move-assigns an allocator from an existing one.
- Parameters
-
other | the other allocator to move |
- Returns
- reference to
(*this)
◆ try_allocate()
owner<void*> bit::memory::allocator_reference::try_allocate |
( |
std::size_t |
size, |
|
|
std::size_t |
align |
|
) |
| |
|
noexcept |
Allocates a block from the underlying block allocator.
- Parameters
-
size | the size of the allocation |
align | the alignment of the allocation |
- Returns
- the allocated pointer
◆ make_stateless_allocator_reference
Makes an allocator_reference that refers to a stateless allocator.
This creates a reference to any stateless allocator that doesn't require an actual instantiation.
- Template Parameters
-
StatelessAllocator | the type of a stateless allocator |
The documentation for this class was generated from the following file: