173 <<
"AhArenaAllocator: cannot allocate " <<
size <<
" bytes";
207 other.base_addr_ =
nullptr;
208 other.curr_addr_ =
nullptr;
209 other.end_addr_ =
nullptr;
210 other.owns_memory_ =
false;
233 other.base_addr_ =
nullptr;
234 other.curr_addr_ =
nullptr;
235 other.end_addr_ =
nullptr;
236 other.owns_memory_ =
false;
311 return reinterpret_cast<void*
>(
aligned);
352 template <
typename T,
typename...
Args>
358 return new (ptr)
T(std::forward<Args>(
args)...);
371 template <
typename T>
376 static_cast<T*
>(ptr)->~
T();
441 const auto p =
static_cast<const char*
>(ptr);
477template <
class T,
typename...
Args>
481 std::forward<Args>(
args)...);
Exception handling system with formatted messages for Aleph-w.
#define ah_runtime_error_if(C)
Throws std::runtime_error if condition holds.
Core header for the Aleph-w library.
Arena allocator for fast bump-pointer allocation.
const void * base_addr() const noexcept
Get base address of the arena.
AhArenaAllocator(const AhArenaAllocator &)=delete
AhArenaAllocator(AhArenaAllocator &&other) noexcept
Move constructor.
AhArenaAllocator & operator=(const AhArenaAllocator &)=delete
const void * next_avail_addr() const noexcept
Get next available address (current allocation pointer).
void deallocate(const void *addr, size_t size) noexcept
AhArenaAllocator(const size_t size=DEFAULT_SIZE)
Construct arena with internally allocated memory.
AhArenaAllocator & operator=(AhArenaAllocator &&other) noexcept
Move assignment operator.
~AhArenaAllocator()
Destructor.
void dealloc(TemplateType tag, void *ptr) noexcept
Destruct and deallocate an object.
bool is_valid() const noexcept
Returns true if the arena is valid (has memory).
bool contains(const void *ptr) const noexcept
Check if a pointer is within this arena's range.
void * alloc(const size_t size) noexcept
Allocate raw memory from the arena.
void * alloc_aligned(const size_t size, const size_t alignment) noexcept
Allocate aligned memory from the arena.
void reset() noexcept
Reset arena, making all memory available again.
const void * end_addr() const noexcept
Get end address (one past last valid byte).
AhArenaAllocator(void *buffer, const size_t size) noexcept
Construct arena from existing memory buffer.
void dealloc(const void *addr, const size_t size) noexcept
Deallocate memory (only effective for LIFO pattern).
bool owns_memory() const noexcept
Returns true if the arena owns its memory.
size_t capacity() const noexcept
Get total arena capacity.
TemplateType
Tag type for dispatching to templated allocation methods.
size_t allocated_size() const noexcept
Get total bytes currently allocated.
bool full() const noexcept
Returns true if the arena is full (no space left).
bool empty() const noexcept
Returns true if the arena is empty (no allocations).
size_t available_size() const noexcept
Get remaining bytes available.
T * alloc(TemplateType tag, Args &&... args)
Allocate and construct an object of type T.
static constexpr size_t DEFAULT_SIZE
Default arena size (1 MB).
AhArenaAllocator(const char *buffer, const size_t size) noexcept
Overload for const buffer (uses const_cast internally).
void * allocate(size_t size) noexcept
Main namespace for Aleph-w library functions.
void dealloc(AhArenaAllocator &arena, T *ptr) noexcept
Alias for deallocate (backward compatibility).
size_t size(Node *root) noexcept
std::decay_t< typename HeadC::Item_Type > T
T * allocate(AhArenaAllocator &arena, Args &&... args)
Allocate and construct an object in an arena.
void deallocate(AhArenaAllocator &arena, T *ptr) noexcept
Destruct and deallocate an object from an arena.
DynList< T > maps(const C &c, Op op)
Classic map operation.