12#if HX_USE_MACROS_WITH_MODULE
13#error Header does not provide macros alone.
24template<
typename T_, hx
size_t fixed_capacity_>
36#if (HX_HARDENING_MODE) == HX_HARDENING_MODE_DEBUG
37 ::memset(m_data_, 0xab,
sizeof m_data_);
45 const T_*
data(
void)
const {
return reinterpret_cast<const T_*
>(m_data_); }
48 T_*
data(
void) {
return reinterpret_cast<T_*
>(m_data_); }
58 (void)allocator_; (void)alignment_;
66 alignas(T_)
char m_data_[fixed_capacity_ *
hxsizeof<T_>()];
96 const T_*
data(
void)
const {
return m_data_; }
99 T_*
data(
void) {
return m_data_; }
108 if(size_ == m_capacity_) {
112 m_data_ =
static_cast<T_*
>(
hxmalloc_ext(
sizeof(T_) *
static_cast<size_t>(size_), allocator_, alignment_));
void reserve_storage(hxsize_t size_, hxsystem_allocator_t allocator_=hxsystem_allocator_current, hxalignment_t alignment_=hxalignment)
Capacity is set by first call to reserve_storage and may not be modified.
Definition hxallocator.hpp:105
T * data(void)
Returns a pointer to a potentially uninitialized array of T.
Definition hxallocator.hpp:99
const T * data(void) const
Returns a pointer to a const and potentially uninitialized array of T.
Definition hxallocator.hpp:96
T value_t
value_t - Publishes the value type.
Definition hxallocator.hpp:75
hxallocator(void)
Does not allocate until reserve_storage is called.
Definition hxallocator.hpp:78
hxsize_t capacity(void) const
Returns the number of elements of T allocated.
Definition hxallocator.hpp:93
~hxallocator(void)
Calls hxfree with any allocated memory.
Definition hxallocator.hpp:84
hxallocator<1+> - Provides static allocation when capacity is greater than zero.
Definition hxallocator.hpp:25
hxallocator(void)
Initializes memory to 0xab when HX_HARDENING_MODE == HX_HARDENING_MODE_DEBUG.
Definition hxallocator.hpp:35
const T * data(void) const
Returns a pointer to a const and potentially uninitialized array of T.
Definition hxallocator.hpp:45
T value_t
value_t - Publishes the value type.
Definition hxallocator.hpp:28
void reserve_storage(hxsize_t size_, hxsystem_allocator_t allocator_=hxsystem_allocator_current, hxalignment_t alignment_=hxalignment)
Ensures capacity.
Definition hxallocator.hpp:55
hxsize_t capacity(void) const
Returns the number of elements of T allocated.
Definition hxallocator.hpp:42
T * data(void)
Returns a pointer to a potentially uninitialized array of T.
Definition hxallocator.hpp:48
HX_NS_BEGIN_ constexpr hxsize_t hxallocator_dynamic_capacity
hxallocator_dynamic_capacity - A capacity value that allows for dynamic allocation.
Definition hxallocator.hpp:20
@ hxsystem_allocator_current
hxsystem_allocator_current - Use current allocation scope.
Definition hxmemory_manager.h:82
int hxsystem_allocator_t
hxsystem_allocator_t - This is extendable by the application.
Definition hxmemory_manager.h:77
void hxfree(void *ptr_) hxattr_noexcept hxattr_hot
hxfree - Frees memory previously allocated with hxmalloc or hxmalloc_ext.
unsigned int hxalignment_t
hxalignment_t - A positive integer power of 2 for aligning allocations.
Definition hxmemory_manager.h:64
void * hxmalloc_ext(size_t size_, hxsystem_allocator_t allocator_, hxalignment_t alignment_) hxattr_noexcept hxattr_allocator(hxfree) hxattr_hot
hxmalloc_ext - Allocates memory of the specified size with a specific memory manager and alignment.
constexpr hxalignment_t hxalignment
hxalignment - The default alignment.
Definition hxmemory_manager.h:69
#define hxinline_constexpr
hxinline_constexpr - Enables C++17 compatable "inline constexpr" usage for variables so they can be e...
Definition hxsettings.h:272
#define hxattr_nodiscard
hxattr_nodiscard - Indicates the caller should not discard the return value.
Definition hxsettings.h:89
Provides core macros, memory management and feature detection.
#define hxnull
hxnull - The null pointer value for a given pointer type represented by the numeric constant 0.
Definition libhatchet.h:277
constexpr hxsize_t hxsizeof(void)
hxsizeof - Returns the size of a type or expression as hxsize_t.
Definition libhatchet.h:288
#define hxassert_always(x_,...)
hxassert_always(bool x, ...) - Logs an error and terminates execution if x is false.
Definition libhatchet.h:121
ptrdiff_t hxsize_t
hxsize_t - A signed size type, same as ssize_t or ptrdiff_t.
Definition libhatchet.h:209