Helios Engine 0.1.0
A modular ECS based data-oriented C++23 game engine
 
Loading...
Searching...
No Matches
allocator_traits.hpp File Reference
#include <helios/core_pch.hpp>
#include <algorithm>
#include <concepts>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <type_traits>

Go to the source code of this file.

Classes

struct  helios::memory::AllocatorStats
 Statistics for tracking allocator usage. More...
 
struct  helios::memory::AllocationResult
 Result type for allocation operations. More...
 

Namespaces

namespace  helios
 
namespace  helios::memory
 

Concepts

concept  helios::memory::Allocator
 Concept for basic allocator interface.
 
concept  helios::memory::ResettableAllocator
 Concept for allocators that can be reset/cleared.
 
concept  helios::memory::AllocatorWithStats
 Concept for allocators that provide statistics.
 

Functions

constexpr size_t helios::memory::AlignUp (size_t size, size_t alignment) noexcept
 Helper function to align a size up to the given alignment.
 
void * helios::memory::AlignUpPtr (void *ptr, size_t alignment) noexcept
 Helper function to align a pointer up to the given alignment.
 
bool helios::memory::IsAligned (const void *ptr, size_t alignment) noexcept
 Helper function to check if a pointer is aligned.
 
constexpr bool helios::memory::IsPowerOfTwo (size_t size) noexcept
 Helper function to check if a size is a power of 2.
 
size_t helios::memory::CalculatePadding (const void *ptr, size_t alignment) noexcept
 Calculate padding needed for alignment.
 
size_t helios::memory::CalculatePaddingWithHeader (const void *ptr, size_t alignment, size_t header_size) noexcept
 Calculate padding with header for alignment.
 
template<typename T , Allocator Alloc>
constexpr T * helios::memory::Allocate (Alloc &allocator) noexcept
 
template<typename T , Allocator Alloc>
constexpr T * helios::memory::Allocate (Alloc &allocator, size_t count) noexcept
 
template<typename T , Allocator Alloc, typename... Args>
requires std::constructible_from<T, Args...>
constexpr T * helios::memory::AllocateAndConstruct (Alloc &allocator, Args &&... args) noexcept(std::is_nothrow_constructible_v< T, Args... >)
 
template<typename T , Allocator Alloc>
requires std::default_initializable<T>
constexpr T * helios::memory::AllocateAndConstructArray (Alloc &allocator, size_t count) noexcept(std::is_nothrow_default_constructible_v< T >)
 

Variables

constexpr size_t helios::memory::kDefaultAlignment = 64
 Default alignment for allocations (cache line size for most modern CPUs).
 
constexpr size_t helios::memory::kMinAlignment = alignof(std::max_align_t)
 Minimum alignment for any allocation.