![]() |
MAGE
v0.171.0
Matthias Advanced Game Engine
|
#include <memory_arena.hpp>
Public Types | |
using | value_type = T |
using | size_type = std::size_t |
using | difference_type = std::ptrdiff_t |
using | propagate_on_container_move_assignment = std::true_type |
using | is_always_equal = std::false_type |
Public Member Functions | |
Allocator (const Allocator &allocator) noexcept=default | |
Allocator (Allocator &&allocator) noexcept=default | |
template<typename U > | |
Allocator (const Allocator< U > &allocator) noexcept | |
~Allocator ()=default | |
Allocator & | operator= (const Allocator &allocator)=delete |
Allocator & | operator= (Allocator &&allocator) noexcept=default |
T * | allocate (std::size_t count) |
T * | allocate (std::size_t count, [[maybe_unused]] const void *hint) |
void | deallocate ([[maybe_unused]] T *data, [[maybe_unused]] std::size_t count) const noexcept |
template<typename U > | |
bool | operator== (const Allocator< U > &rhs) const noexcept |
template<typename U > | |
bool | operator!= (const Allocator< U > &rhs) const noexcept |
Private Member Functions | |
Allocator (NotNull< MemoryArena * > memory_arena) noexcept | |
Private Attributes | |
NotNull< MemoryArena *> | m_memory_arena |
Friends | |
class | MemoryArena |
A class of allocators for memory arenas.
T | The data type. |
using mage::MemoryArena::Allocator< T >::difference_type = std::ptrdiff_t |
using mage::MemoryArena::Allocator< T >::is_always_equal = std::false_type |
using mage::MemoryArena::Allocator< T >::propagate_on_container_move_assignment = std::true_type |
using mage::MemoryArena::Allocator< T >::size_type = std::size_t |
using mage::MemoryArena::Allocator< T >::value_type = T |
|
defaultnoexcept |
Constructs an allocator from the given allocator.
[in] | allocator | A reference to the allocator to copy. |
|
defaultnoexcept |
Constructs an allocator by moving the given allocator.
[in] | allocator | A reference to the allocator to move. |
|
noexcept |
Constructs an allocator from the given allocator.
U | The data type. |
[in] | allocator | A reference to the allocator to copy. |
|
default |
Destructs this allocator.
|
explicitprivatenoexcept |
Constructs an allocator.
[in] | memory_arena | A pointer to the memory arena. |
T* mage::MemoryArena::Allocator< T >::allocate | ( | std::size_t | count | ) |
Allocates a block of storage with a size large enough to contain count elements of type T
, and returns a pointer to the first element.
[in] | count | The number of objects of type T to allocate in memory. |
std::bad_alloc | Failed to allocate the memory block. |
T* mage::MemoryArena::Allocator< T >::allocate | ( | std::size_t | count, |
[[maybe_unused] ] const void * | hint | ||
) |
Allocates a block of storage with a size large enough to contain count elements of type T
, and returns a pointer to the first element.
[in] | count | The number of objects of type T to allocate in memory. |
[in] | hint | Either nullptr or a value previously obtained by another call to mage::MemoryArena::Allocator<T>::allocate(std::size_t) and not yet freed with mage::MemoryArena::Allocator<T>::deallocate(T*, std::size_t). When not equal to nullptr , this value may be used as a hint to improve performance by allocating the new block near the one specified. The address of an adjacent element is often a good choice. |
std::bad_alloc | Failed to allocate the memory block. |
|
noexcept |
Releases a block of storage previously allocated with mage::MemoryArena::Allocator<T>::allocate(std::size_t) and not yet released.
[in] | data | A pointer to the memory block that needs to be released. |
[in] | count | The number of objects of type T allocated on the call to allocate this block of storage. |
|
noexcept |
Compares this allocator to the given allocator for non-equality.
U | The data type. |
[in] | rhs | A reference to the allocator to compare with. |
true
if and only if storage allocated from this allocator cannot be deallocated from the given allocator, and vice versa. false
otherwise.
|
delete |
Copies the given allocator to this allocator.
[in] | allocator | A reference to the allocator to copy. |
|
defaultnoexcept |
Moves the given allocator to this allocator.
[in] | allocator | A reference to the allocator to move. |
|
noexcept |
Compares this allocator to the given allocator for equality.
U | The data type. |
[in] | rhs | A reference to the allocator to compare with. |
true
if and only if storage allocated from this allocator can be deallocated from the given allocator, and vice versa. false
otherwise.
|
friend |
|
private |
A pointer to the memory arena of this allocator.