Helios Engine
A modular ECS based data-oriented C++23 game engine framework
Loading...
Searching...
No Matches
helios::container::TypedBufferArray< Allocator > Class Template Reference

Type-erased sequential byte storage for a single type (array variant). More...

#include <typed_buffer_array.hpp>

Public Types

using allocator_type = Allocator
using size_type = size_t
using difference_type = ptrdiff_t
using TypeIndex = utils::TypeIndex
using ContainerType = std::vector<std::byte, allocator_type>

Public Member Functions

constexpr TypedBufferArray () noexcept(std::is_nothrow_default_constructible_v< ContainerType >)=default
 Default constructor.
constexpr TypedBufferArray (const allocator_type &alloc) noexcept(std::is_nothrow_constructible_v< ContainerType, const allocator_type & >)
 Constructs an empty storage with a custom allocator.
constexpr TypedBufferArray (std::pmr::memory_resource *resource) noexcept(std::is_nothrow_constructible_v< allocator_type, std::pmr::memory_resource * >)
 Constructs an empty storage from a PMR memory resource.
 TypedBufferArray (std::nullptr_t)=delete
template<TypedBufferStorable T>
requires std::default_initializable<T>
constexpr TypedBufferArray (size_type count)
 Constructs storage with count default-inserted elements of type T.
template<TypedBufferStorable T>
requires std::copy_constructible<T>
constexpr TypedBufferArray (size_type count, const T &value)
 Constructs storage with count copies of value.
template<std::input_iterator InputIt>
requires TypedBufferStorable<std::iter_value_t<InputIt>>
constexpr TypedBufferArray (InputIt first, InputIt last)
 Constructs storage from iterator range.
template<TypedBufferStorable T>
requires std::copy_constructible<T>
constexpr TypedBufferArray (std::initializer_list< T > init)
 Constructs storage from initializer list.
constexpr TypedBufferArray (const TypedBufferArray &other)
constexpr TypedBufferArray (const TypedBufferArray &other, const allocator_type &alloc) noexcept(std::is_nothrow_constructible_v< ContainerType, const allocator_type & >)
constexpr TypedBufferArray (TypedBufferArray &&other) noexcept(std::is_nothrow_move_constructible_v< ContainerType >)
constexpr TypedBufferArray (TypedBufferArray &&other, const allocator_type &alloc) noexcept(std::is_nothrow_constructible_v< ContainerType, const allocator_type & >)
constexpr ~TypedBufferArray () noexcept
constexpr TypedBufferArrayoperator= (const TypedBufferArray &other)
constexpr TypedBufferArrayoperator= (TypedBufferArray &&other) noexcept(std::is_nothrow_move_assignable_v< ContainerType >)
template<TypedBufferStorable T>
requires std::copy_constructible<T>
constexpr TypedBufferArrayoperator= (std::initializer_list< T > init)
 Assignment from initializer list.
template<TypedBufferStorable T>
constexpr void ChangeType () noexcept
 Changes the stored type, destroying current elements but keeping memory.
constexpr void Reset () noexcept
 Resets storage to empty state with no associated type.
template<TypedBufferStorable T>
void PushBack (T &&value)
 Appends a value to the end.
template<TypedBufferStorable T, typename... Args>
requires std::constructible_from<T, Args...>
T & EmplaceBack (Args &&... args)
 Constructs an element in-place at the end.
template<TypedBufferStorable T, typename... Args>
requires std::constructible_from<T, Args...>
T & Emplace (size_type pos, Args &&... args)
 Constructs an element in-place at the specified position.
template<TypedBufferStorable T>
T & Insert (size_type pos, T &&value)
 Inserts a value at the specified position.
template<TypedBufferStorable T>
requires std::copy_constructible<T>
T * Insert (size_type pos, size_type count, const T &value)
 Inserts count copies of value at the specified position.
template<std::input_iterator InputIt>
requires TypedBufferStorable<std::iter_value_t<InputIt>>
auto Insert (size_type pos, InputIt first, InputIt last) -> std::iter_value_t< InputIt > *
 Inserts elements from iterator range at the specified position.
template<TypedBufferStorable T>
requires std::copy_constructible<T>
T * Insert (size_type pos, std::initializer_list< T > init)
 Inserts elements from initializer list at the specified position.
template<std::ranges::input_range Range>
requires TypedBufferStorable<std::ranges::range_value_t<Range>>
void AppendRange (Range &&range)
 Appends elements from a range to the end.
template<std::ranges::input_range Range>
requires TypedBufferStorable<std::ranges::range_value_t<Range>>
auto InsertRange (size_type pos, Range &&range) -> std::ranges::range_value_t< Range > *
 Inserts elements from a range at the specified position.
constexpr void PopBack () noexcept
 Removes the last stored value.
constexpr void Erase (size_type pos)
 Erases the element at the specified position.
constexpr void Erase (size_type first_pos, size_type last_pos)
 Erases elements in the range [first_pos, last_pos).
constexpr void Clear () noexcept
 Clears all stored data, but retains type information.
constexpr void Reserve (size_type count)
 Reserves space for at least the specified number of elements.
constexpr void ShrinkToFit ()
 Reduces capacity to fit the current size.
template<TypedBufferStorable T>
requires std::default_initializable<T>
void Resize (size_type count)
 Resizes the storage to contain count elements (default-initialized).
template<TypedBufferStorable T>
requires std::copy_constructible<T>
void Resize (size_type count, const T &value)
 Resizes the storage to contain count elements.
template<TypedBufferStorable T>
T & At (size_type index) noexcept
 Access element at index.
template<TypedBufferStorable T>
const T & At (size_type index) const noexcept
 Access element at index (const).
template<TypedBufferStorable T>
T & Front () noexcept
 Access the first element.
template<TypedBufferStorable T>
const T & Front () const noexcept
 Access the first element (const).
template<TypedBufferStorable T>
T & Back () noexcept
 Access the last element.
template<TypedBufferStorable T>
const T & Back () const noexcept
 Access the last element (const).
template<typename OtherAllocator>
constexpr void Merge (const TypedBufferArray< OtherAllocator > &other)
 Merges all elements from another TypedBufferArray into this one.
template<typename OtherAllocator>
constexpr void Merge (TypedBufferArray< OtherAllocator > &&other)
 Merges all elements from another TypedBufferArray into this one.
constexpr void Swap (TypedBufferArray &other) noexcept(std::is_nothrow_swappable_v< ContainerType >)
 Swaps contents with another storage.
void Swap (size_type index, size_type other_index)
 Swaps two elements within the buffer at the given indices (type-erased).
template<TypedBufferStorable T>
void Swap (size_type index, size_type other_index)
 Swaps two elements within the buffer at the given indices (typed).
constexpr bool Empty () const noexcept
 Checks if the storage is empty.
constexpr bool HasType () const noexcept
 Checks if a type is currently associated with this storage.
template<TypedBufferStorable T>
constexpr bool IsType () const noexcept
 Checks if the stored type matches T.
constexpr TypeIndex StoredTypeId () const noexcept
 Gets the current stored type index.
constexpr size_type Size () const noexcept
 Returns the number of stored elements.
constexpr size_type SizeBytes () const noexcept
 Returns the number of bytes occupied by stored elements.
constexpr size_type ElementSize () const noexcept
 Returns the size of each element in bytes.
constexpr size_type Capacity () const noexcept
 Returns the capacity in number of elements.
template<TypedBufferStorable T>
auto Data () noexcept -> std::span< T >
 Retrieves a span of all stored values.
template<TypedBufferStorable T>
auto Data () const noexcept -> std::span< const T >
 Retrieves a const span of all stored values.
constexpr auto Bytes () const noexcept -> std::span< const std::byte >
 Retrieves a const byte span of all stored data (type-erased).
template<TypedBufferStorable T>
T * begin () noexcept
 Returns iterator to the beginning.
template<TypedBufferStorable T>
const T * begin () const noexcept
 Returns const iterator to the beginning.
template<TypedBufferStorable T>
const T * cbegin () const noexcept
 Returns const iterator to the beginning.
template<TypedBufferStorable T>
T * end () noexcept
 Returns iterator past the last element.
template<TypedBufferStorable T>
const T * end () const noexcept
 Returns const iterator past the last element.
template<TypedBufferStorable T>
const T * cend () const noexcept
 Returns const iterator past the last element.
template<TypedBufferStorable T>
auto rbegin () noexcept -> std::reverse_iterator< T * >
 Returns reverse iterator to the last element.
template<TypedBufferStorable T>
auto rbegin () const noexcept -> std::reverse_iterator< const T * >
 Returns const reverse iterator to the last element.
template<TypedBufferStorable T>
auto crbegin () const noexcept -> std::reverse_iterator< const T * >
 Returns const reverse iterator to the last element.
template<TypedBufferStorable T>
auto rend () noexcept -> std::reverse_iterator< T * >
 Returns reverse iterator before the first element.
template<TypedBufferStorable T>
auto rend () const noexcept -> std::reverse_iterator< const T * >
 Returns const reverse iterator before the first element.
template<TypedBufferStorable T>
auto crend () const noexcept -> std::reverse_iterator< const T * >
 Returns const reverse iterator before the first element.
template<TypedBufferStorable T>
requires std::copy_constructible<T>
constexpr auto operator= (std::initializer_list< T > init) -> TypedBufferArray &

Static Public Member Functions

template<TypedBufferStorable T>
static consteval TypeIndex TypeIndexOf () noexcept
 Gets the type index for type T.

Friends

template<typename OtherA>
class TypedBufferArray
constexpr void swap (TypedBufferArray &lhs, TypedBufferArray &rhs) noexcept(std::is_nothrow_swappable_v< ContainerType >)

Detailed Description

template<typename Allocator = std::allocator<std::byte>>
class helios::container::TypedBufferArray< Allocator >

Type-erased sequential byte storage for a single type (array variant).

Stores multiple instances of a type in a contiguous std::vector<std::byte> buffer. The stored type is not fixed at class instantiation but is verified at runtime. Object lifetimes are properly managed. Trivially-copyable types are fast-pathed.

Template Parameters
AllocatorThe allocator type for the byte storage (default: std::allocator<std::byte>)

Definition at line 33 of file typed_buffer_array.hpp.

Member Typedef Documentation

◆ allocator_type

template<typename Allocator = std::allocator<std::byte>>
using helios::container::TypedBufferArray< Allocator >::allocator_type = Allocator

Definition at line 35 of file typed_buffer_array.hpp.

◆ ContainerType

template<typename Allocator = std::allocator<std::byte>>
using helios::container::TypedBufferArray< Allocator >::ContainerType = std::vector<std::byte, allocator_type>

Definition at line 40 of file typed_buffer_array.hpp.

◆ difference_type

template<typename Allocator = std::allocator<std::byte>>
using helios::container::TypedBufferArray< Allocator >::difference_type = ptrdiff_t

Definition at line 37 of file typed_buffer_array.hpp.

◆ size_type

template<typename Allocator = std::allocator<std::byte>>
using helios::container::TypedBufferArray< Allocator >::size_type = size_t

Definition at line 36 of file typed_buffer_array.hpp.

◆ TypeIndex

template<typename Allocator = std::allocator<std::byte>>
using helios::container::TypedBufferArray< Allocator >::TypeIndex = utils::TypeIndex

Definition at line 38 of file typed_buffer_array.hpp.

Constructor & Destructor Documentation

◆ TypedBufferArray() [1/12]

template<typename Allocator = std::allocator<std::byte>>
helios::container::TypedBufferArray< Allocator >::TypedBufferArray ( ) const
constexprdefaultnoexcept

Default constructor.

Creates an empty storage with no associated type.

◆ TypedBufferArray() [2/12]

template<typename Allocator = std::allocator<std::byte>>
helios::container::TypedBufferArray< Allocator >::TypedBufferArray ( const allocator_type & alloc)
inlineexplicitconstexprnoexcept

Constructs an empty storage with a custom allocator.

Parameters
allocAllocator instance to use for the underlying container

Definition at line 57 of file typed_buffer_array.hpp.

◆ TypedBufferArray() [3/12]

template<typename Allocator = std::allocator<std::byte>>
helios::container::TypedBufferArray< Allocator >::TypedBufferArray ( std::pmr::memory_resource * resource)
inlineexplicitconstexprnoexcept

Constructs an empty storage from a PMR memory resource.

Enabled only when allocator_type is constructible from std::pmr::memory_resource*.

Parameters
resourceMemory resource used to construct allocator

Definition at line 67 of file typed_buffer_array.hpp.

◆ TypedBufferArray() [4/12]

template<typename Allocator = std::allocator<std::byte>>
helios::container::TypedBufferArray< Allocator >::TypedBufferArray ( std::nullptr_t )
delete

◆ TypedBufferArray() [5/12]

template<typename Allocator>
requires std::default_initializable<T>
template<TypedBufferStorable T>
requires std::default_initializable<T>
helios::container::TypedBufferArray< Allocator >::TypedBufferArray ( size_type count)
explicitconstexpr

Constructs storage with count default-inserted elements of type T.

Template Parameters
TThe type to store
Parameters
countNumber of elements to default-construct

Definition at line 723 of file typed_buffer_array.hpp.

◆ TypedBufferArray() [6/12]

template<typename Allocator>
requires std::copy_constructible<T>
template<TypedBufferStorable T>
requires std::copy_constructible<T>
helios::container::TypedBufferArray< Allocator >::TypedBufferArray ( size_type count,
const T & value )
constexpr

Constructs storage with count copies of value.

Template Parameters
TThe type to store
Parameters
countNumber of elements
valueValue to copy

Definition at line 739 of file typed_buffer_array.hpp.

◆ TypedBufferArray() [7/12]

template<typename Allocator>
requires TypedBufferStorable<std::iter_value_t<InputIt>>
template<std::input_iterator InputIt>
requires TypedBufferStorable<std::iter_value_t<InputIt>>
helios::container::TypedBufferArray< Allocator >::TypedBufferArray ( InputIt first,
InputIt last )
constexpr

Constructs storage from iterator range.

Template Parameters
InputItInput iterator type
Parameters
firstBeginning of range
lastEnd of range

Definition at line 758 of file typed_buffer_array.hpp.

◆ TypedBufferArray() [8/12]

template<typename Allocator = std::allocator<std::byte>>
template<TypedBufferStorable T>
requires std::copy_constructible<T>
helios::container::TypedBufferArray< Allocator >::TypedBufferArray ( std::initializer_list< T > init)
inlineconstexpr

Constructs storage from initializer list.

Template Parameters
TThe type to store
Parameters
initInitializer list

Definition at line 114 of file typed_buffer_array.hpp.

◆ TypedBufferArray() [9/12]

template<typename Allocator>
helios::container::TypedBufferArray< Allocator >::TypedBufferArray ( const TypedBufferArray< Allocator > & other)
constexpr

Definition at line 782 of file typed_buffer_array.hpp.

◆ TypedBufferArray() [10/12]

template<typename Allocator>
helios::container::TypedBufferArray< Allocator >::TypedBufferArray ( const TypedBufferArray< Allocator > & other,
const allocator_type & alloc )
constexprnoexcept

Definition at line 805 of file typed_buffer_array.hpp.

◆ TypedBufferArray() [11/12]

template<typename Allocator>
helios::container::TypedBufferArray< Allocator >::TypedBufferArray ( TypedBufferArray< Allocator > && other)
constexprnoexcept

Definition at line 832 of file typed_buffer_array.hpp.

◆ TypedBufferArray() [12/12]

template<typename Allocator>
helios::container::TypedBufferArray< Allocator >::TypedBufferArray ( TypedBufferArray< Allocator > && other,
const allocator_type & alloc )
constexprnoexcept

Definition at line 843 of file typed_buffer_array.hpp.

◆ ~TypedBufferArray()

template<typename Allocator = std::allocator<std::byte>>
helios::container::TypedBufferArray< Allocator >::~TypedBufferArray ( )
inlineconstexprnoexcept

Definition at line 132 of file typed_buffer_array.hpp.

Member Function Documentation

◆ AppendRange()

template<typename Allocator>
requires TypedBufferStorable<std::ranges::range_value_t<Range>>
template<std::ranges::input_range Range>
requires TypedBufferStorable<std::ranges::range_value_t<Range>>
void helios::container::TypedBufferArray< Allocator >::AppendRange ( Range && range)
inline

Appends elements from a range to the end.

Warning
Triggers assertion if type mismatch and storage is not empty.
Template Parameters
RangeRange type
Parameters
rangeThe range to append

Definition at line 1080 of file typed_buffer_array.hpp.

◆ At() [1/2]

template<typename Allocator>
template<TypedBufferStorable T>
const T & helios::container::TypedBufferArray< Allocator >::At ( size_type index) const
inlinenodiscardnoexcept

Access element at index (const).

Warning
Triggers assertion if index >= Size() or type mismatch.
Template Parameters
TThe type of elements (must match stored type)
Parameters
indexElement index
Returns
Const reference to element

Definition at line 1304 of file typed_buffer_array.hpp.

◆ At() [2/2]

template<typename Allocator>
template<TypedBufferStorable T>
T & helios::container::TypedBufferArray< Allocator >::At ( size_type index)
inlinenodiscardnoexcept

Access element at index.

Warning
Triggers assertion if index >= Size() or type mismatch.
Template Parameters
TThe type of elements (must match stored type)
Parameters
indexElement index
Returns
Reference to element

Definition at line 1294 of file typed_buffer_array.hpp.

◆ Back() [1/2]

template<typename Allocator>
template<TypedBufferStorable T>
const T & helios::container::TypedBufferArray< Allocator >::Back ( ) const
inlinenodiscardnoexcept

Access the last element (const).

Warning
Triggers assertion if storage is empty or type mismatch.
Template Parameters
TThe type of elements (must match stored type)
Returns
Const reference to the last element

Definition at line 1345 of file typed_buffer_array.hpp.

◆ Back() [2/2]

template<typename Allocator>
template<TypedBufferStorable T>
T & helios::container::TypedBufferArray< Allocator >::Back ( )
inlinenodiscardnoexcept

Access the last element.

Warning
Triggers assertion if storage is empty or type mismatch.
Template Parameters
TThe type of elements (must match stored type)
Returns
Reference to the last element

Definition at line 1335 of file typed_buffer_array.hpp.

◆ begin() [1/2]

template<typename Allocator = std::allocator<std::byte>>
template<TypedBufferStorable T>
const T * helios::container::TypedBufferArray< Allocator >::begin ( ) const
inlinenodiscardnoexcept

Returns const iterator to the beginning.

Template Parameters
TThe type of elements (must match stored type)
Returns
Const iterator to the first element, or nullptr if no elements stored

Definition at line 571 of file typed_buffer_array.hpp.

◆ begin() [2/2]

template<typename Allocator = std::allocator<std::byte>>
template<TypedBufferStorable T>
T * helios::container::TypedBufferArray< Allocator >::begin ( )
inlinenodiscardnoexcept

Returns iterator to the beginning.

Template Parameters
TThe type of elements (must match stored type)
Returns
Iterator to the first element, or nullptr if no elements stored

Definition at line 560 of file typed_buffer_array.hpp.

◆ Bytes()

template<typename Allocator = std::allocator<std::byte>>
auto helios::container::TypedBufferArray< Allocator >::Bytes ( ) const -> std::span< const std::byte >
inlinenodiscardconstexprnoexcept

Retrieves a const byte span of all stored data (type-erased).

Returns
A const byte span containing all stored bytes, or empty span if no type is set (even if bytes are present)

Definition at line 549 of file typed_buffer_array.hpp.

◆ Capacity()

template<typename Allocator>
auto helios::container::TypedBufferArray< Allocator >::Capacity ( ) const
nodiscardconstexprnoexcept

Returns the capacity in number of elements.

Returns
Capacity in number of elements, or 0 if no type is set

Definition at line 1532 of file typed_buffer_array.hpp.

◆ cbegin()

template<typename Allocator = std::allocator<std::byte>>
template<TypedBufferStorable T>
const T * helios::container::TypedBufferArray< Allocator >::cbegin ( ) const
inlinenodiscardnoexcept

Returns const iterator to the beginning.

Template Parameters
TThe type of elements (must match stored type)
Returns
Const iterator to the first element, or nullptr if no elements stored

Definition at line 582 of file typed_buffer_array.hpp.

◆ cend()

template<typename Allocator = std::allocator<std::byte>>
template<TypedBufferStorable T>
const T * helios::container::TypedBufferArray< Allocator >::cend ( ) const
inlinenodiscardnoexcept

Returns const iterator past the last element.

Template Parameters
TThe type of elements (must match stored type)
Returns
Const iterator past the last element, or nullptr if no elements stored

Definition at line 614 of file typed_buffer_array.hpp.

◆ ChangeType()

template<typename Allocator>
template<TypedBufferStorable T>
void helios::container::TypedBufferArray< Allocator >::ChangeType ( )
constexprnoexcept

Changes the stored type, destroying current elements but keeping memory.

Destroys all current elements and resets size to 0. Memory is retained.

Template Parameters
TThe new type to store

Definition at line 952 of file typed_buffer_array.hpp.

◆ Clear()

template<typename Allocator>
void helios::container::TypedBufferArray< Allocator >::Clear ( )
constexprnoexcept

Clears all stored data, but retains type information.

Definition at line 1190 of file typed_buffer_array.hpp.

◆ crbegin()

template<typename Allocator = std::allocator<std::byte>>
template<TypedBufferStorable T>
auto helios::container::TypedBufferArray< Allocator >::crbegin ( ) const -> std::reverse_iterator< const T * >
inlinenodiscardnoexcept

Returns const reverse iterator to the last element.

Template Parameters
TThe type of elements (must match stored type)
Returns
Const reverse iterator to the last element, or nullptr if no elements stored

Definition at line 648 of file typed_buffer_array.hpp.

◆ crend()

template<typename Allocator = std::allocator<std::byte>>
template<TypedBufferStorable T>
auto helios::container::TypedBufferArray< Allocator >::crend ( ) const -> std::reverse_iterator< const T * >
inlinenodiscardnoexcept

Returns const reverse iterator before the first element.

Template Parameters
TThe type of elements (must match stored type)
Returns
Const reverse iterator before the first element, or nullptr if no elements stored

Definition at line 682 of file typed_buffer_array.hpp.

◆ Data() [1/2]

template<typename Allocator>
template<TypedBufferStorable T>
auto helios::container::TypedBufferArray< Allocator >::Data ( ) const -> std::span< const T >
inlinenodiscardnoexcept

Retrieves a const span of all stored values.

Warning
Triggers assertion if type mismatch.
Template Parameters
TThe type of elements (must match stored type)
Returns
A const span containing all values, or empty span if no values stored

Definition at line 1551 of file typed_buffer_array.hpp.

◆ Data() [2/2]

template<typename Allocator>
template<TypedBufferStorable T>
auto helios::container::TypedBufferArray< Allocator >::Data ( ) -> std::span< T >
inlinenodiscardnoexcept

Retrieves a span of all stored values.

Warning
Triggers assertion if type mismatch.
Template Parameters
TThe type of elements (must match stored type)
Returns
A span containing all values, or empty span if no values stored

Definition at line 1542 of file typed_buffer_array.hpp.

◆ ElementSize()

template<typename Allocator = std::allocator<std::byte>>
size_type helios::container::TypedBufferArray< Allocator >::ElementSize ( ) const
inlinenodiscardconstexprnoexcept

Returns the size of each element in bytes.

Returns
Size of each element in bytes, or 0 if no type is set

Definition at line 515 of file typed_buffer_array.hpp.

◆ Emplace()

template<typename Allocator>
requires std::constructible_from<T, Args...>
template<TypedBufferStorable T, typename... Args>
requires std::constructible_from<T, Args...>
T & helios::container::TypedBufferArray< Allocator >::Emplace ( size_type pos,
Args &&... args )
inline

Constructs an element in-place at the specified position.

Warning
Triggers assertion if pos > Size() or type mismatch and storage is not empty.
Template Parameters
TThe type to construct (must match stored type)
ArgsConstructor argument types
Parameters
posPosition (element index)
argsArguments forwarded to the constructor
Returns
Reference to the emplaced element

Definition at line 992 of file typed_buffer_array.hpp.

◆ EmplaceBack()

template<typename Allocator>
requires std::constructible_from<T, Args...>
template<TypedBufferStorable T, typename... Args>
requires std::constructible_from<T, Args...>
T & helios::container::TypedBufferArray< Allocator >::EmplaceBack ( Args &&... args)
inline

Constructs an element in-place at the end.

Warning
Triggers assertion if type mismatch and storage is not empty.
Template Parameters
TThe type to construct (must match stored type)
ArgsConstructor argument types
Parameters
argsArguments forwarded to the constructor
Returns
Reference to the emplaced element

Definition at line 980 of file typed_buffer_array.hpp.

◆ Empty()

template<typename Allocator = std::allocator<std::byte>>
bool helios::container::TypedBufferArray< Allocator >::Empty ( ) const
inlinenodiscardconstexprnoexcept

Checks if the storage is empty.

Returns
True if empty, false if a value is stored

Definition at line 458 of file typed_buffer_array.hpp.

◆ end() [1/2]

template<typename Allocator = std::allocator<std::byte>>
template<TypedBufferStorable T>
const T * helios::container::TypedBufferArray< Allocator >::end ( ) const
inlinenodiscardnoexcept

Returns const iterator past the last element.

Template Parameters
TThe type of elements (must match stored type)
Returns
Const iterator past the last element, or nullptr if no elements stored

Definition at line 603 of file typed_buffer_array.hpp.

◆ end() [2/2]

template<typename Allocator = std::allocator<std::byte>>
template<TypedBufferStorable T>
T * helios::container::TypedBufferArray< Allocator >::end ( )
inlinenodiscardnoexcept

Returns iterator past the last element.

Template Parameters
TThe type of elements (must match stored type)
Returns
Iterator past the last element, or nullptr if no elements stored

Definition at line 592 of file typed_buffer_array.hpp.

◆ Erase() [1/2]

template<typename Allocator>
void helios::container::TypedBufferArray< Allocator >::Erase ( size_type first_pos,
size_type last_pos )
constexpr

Erases elements in the range [first_pos, last_pos).

Warning
Triggers assertion if range is invalid or storage has no type.
Parameters
first_posBeginning of range (element index)
last_posEnd of range (element index, exclusive)

Definition at line 1166 of file typed_buffer_array.hpp.

◆ Erase() [2/2]

template<typename Allocator>
void helios::container::TypedBufferArray< Allocator >::Erase ( size_type pos)
constexpr

Erases the element at the specified position.

Warning
Triggers assertion if pos >= Size() or storage has no type.
Parameters
posPosition (element index) to erase

Definition at line 1154 of file typed_buffer_array.hpp.

◆ Front() [1/2]

template<typename Allocator>
template<TypedBufferStorable T>
const T & helios::container::TypedBufferArray< Allocator >::Front ( ) const
inlinenodiscardnoexcept

Access the first element (const).

Warning
Triggers assertion if storage is empty or type mismatch.
Template Parameters
TThe type of elements (must match stored type)
Returns
Const reference to the first element

Definition at line 1325 of file typed_buffer_array.hpp.

◆ Front() [2/2]

template<typename Allocator>
template<TypedBufferStorable T>
T & helios::container::TypedBufferArray< Allocator >::Front ( )
inlinenodiscardnoexcept

Access the first element.

Warning
Triggers assertion if storage is empty or type mismatch.
Template Parameters
TThe type of elements (must match stored type)
Returns
Reference to the first element

Definition at line 1315 of file typed_buffer_array.hpp.

◆ HasType()

template<typename Allocator = std::allocator<std::byte>>
bool helios::container::TypedBufferArray< Allocator >::HasType ( ) const
inlinenodiscardconstexprnoexcept

Checks if a type is currently associated with this storage.

Returns
True if a type is set, false if no type is set

Definition at line 464 of file typed_buffer_array.hpp.

◆ Insert() [1/4]

template<typename Allocator>
requires TypedBufferStorable<std::iter_value_t<InputIt>>
template<std::input_iterator InputIt>
requires TypedBufferStorable<std::iter_value_t<InputIt>>
auto helios::container::TypedBufferArray< Allocator >::Insert ( size_type pos,
InputIt first,
InputIt last ) -> std::iter_value_t< InputIt > *
inline

Inserts elements from iterator range at the specified position.

Warning
Triggers assertion if pos > Size() or type mismatch and storage is not empty.
Template Parameters
InputItInput iterator type
Parameters
posPosition (element index)
firstBeginning of range
lastEnd of range
Returns
Pointer to the first inserted element, or nullptr if range is empty

Definition at line 1038 of file typed_buffer_array.hpp.

◆ Insert() [2/4]

template<typename Allocator>
requires std::copy_constructible<T>
template<TypedBufferStorable T>
requires std::copy_constructible<T>
T * helios::container::TypedBufferArray< Allocator >::Insert ( size_type pos,
size_type count,
const T & value )
inline

Inserts count copies of value at the specified position.

Warning
Triggers assertion if pos > Size() or type mismatch and storage is not empty.
Template Parameters
TThe type to insert (must match stored type)
Parameters
posPosition (element index)
countNumber of copies
valueValue to copy
Returns
Pointer to the first inserted element, or nullptr if count == 0

Definition at line 1011 of file typed_buffer_array.hpp.

◆ Insert() [3/4]

template<typename Allocator = std::allocator<std::byte>>
template<TypedBufferStorable T>
requires std::copy_constructible<T>
T * helios::container::TypedBufferArray< Allocator >::Insert ( size_type pos,
std::initializer_list< T > init )
inline

Inserts elements from initializer list at the specified position.

Warning
Triggers assertion if pos > Size() or type mismatch and storage is not empty.
Template Parameters
TThe type to insert (must match stored type)
Parameters
posPosition (element index)
initInitializer list
Returns
Pointer to the first inserted element, or nullptr if list is empty

Definition at line 255 of file typed_buffer_array.hpp.

◆ Insert() [4/4]

template<typename Allocator = std::allocator<std::byte>>
template<TypedBufferStorable T>
T & helios::container::TypedBufferArray< Allocator >::Insert ( size_type pos,
T && value )
inline

Inserts a value at the specified position.

Warning
Triggers assertion if pos > Size() or type mismatch and storage is not empty.
Template Parameters
TThe type to insert (must match stored type)
Parameters
posPosition (element index)
valueValue to insert
Returns
Reference to the inserted element

Definition at line 209 of file typed_buffer_array.hpp.

◆ InsertRange()

template<typename Allocator>
requires TypedBufferStorable<std::ranges::range_value_t<Range>>
template<std::ranges::input_range Range>
requires TypedBufferStorable<std::ranges::range_value_t<Range>>
auto helios::container::TypedBufferArray< Allocator >::InsertRange ( size_type pos,
Range && range ) -> std::ranges::range_value_t< Range > *
inline

Inserts elements from a range at the specified position.

Warning
Triggers assertion if pos > Size() or type mismatch and storage is not empty.
Template Parameters
RangeRange type
Parameters
posPosition (element index)
rangeThe range to insert
Returns
Pointer to the first inserted element, or nullptr if range is empty

Definition at line 1102 of file typed_buffer_array.hpp.

◆ IsType()

template<typename Allocator = std::allocator<std::byte>>
template<TypedBufferStorable T>
bool helios::container::TypedBufferArray< Allocator >::IsType ( ) const
inlinenodiscardconstexprnoexcept

Checks if the stored type matches T.

Template Parameters
TThe type to check
Returns
true if types match or no type is set

Definition at line 474 of file typed_buffer_array.hpp.

◆ Merge() [1/2]

template<typename Allocator>
template<typename OtherAllocator>
void helios::container::TypedBufferArray< Allocator >::Merge ( const TypedBufferArray< OtherAllocator > & other)
constexpr

Merges all elements from another TypedBufferArray into this one.

Appends all elements from other to the end of this buffer. If this buffer is empty and has no type, it takes ownership of other's state. After merging, other is left in a valid but empty state.

Warning
Triggers assertion if both buffers have types set and they don't match.
Template Parameters
OtherAllocatorThe allocator type of the other buffer
Parameters
otherThe buffer to merge from (will be left empty)

Definition at line 1355 of file typed_buffer_array.hpp.

◆ Merge() [2/2]

template<typename Allocator>
template<typename OtherAllocator>
void helios::container::TypedBufferArray< Allocator >::Merge ( TypedBufferArray< OtherAllocator > && other)
constexpr

Merges all elements from another TypedBufferArray into this one.

Rvalue overload that consumes the source buffer.

Template Parameters
OtherAllocatorThe allocator type of the other buffer
Parameters
otherThe buffer to merge from (will be left empty)

Definition at line 1396 of file typed_buffer_array.hpp.

◆ operator=() [1/4]

template<typename Allocator>
auto helios::container::TypedBufferArray< Allocator >::operator= ( const TypedBufferArray< Allocator > & other)
constexpr

Definition at line 881 of file typed_buffer_array.hpp.

◆ operator=() [2/4]

template<typename Allocator = std::allocator<std::byte>>
template<TypedBufferStorable T>
requires std::copy_constructible<T>
TypedBufferArray & helios::container::TypedBufferArray< Allocator >::operator= ( std::initializer_list< T > init)
constexpr

Assignment from initializer list.

Template Parameters
TThe type to store
Parameters
initInitializer list
Returns
Reference to this

◆ operator=() [3/4]

template<typename Allocator = std::allocator<std::byte>>
template<TypedBufferStorable T>
requires std::copy_constructible<T>
auto helios::container::TypedBufferArray< Allocator >::operator= ( std::initializer_list< T > init) -> TypedBufferArray &
constexpr

Definition at line 932 of file typed_buffer_array.hpp.

◆ operator=() [4/4]

template<typename Allocator>
auto helios::container::TypedBufferArray< Allocator >::operator= ( TypedBufferArray< Allocator > && other)
constexprnoexcept

Definition at line 913 of file typed_buffer_array.hpp.

◆ PopBack()

template<typename Allocator>
void helios::container::TypedBufferArray< Allocator >::PopBack ( )
constexprnoexcept

Removes the last stored value.

Warning
Triggers assertion if storage is empty.

Definition at line 1147 of file typed_buffer_array.hpp.

◆ PushBack()

template<typename Allocator>
template<TypedBufferStorable T>
void helios::container::TypedBufferArray< Allocator >::PushBack ( T && value)
inline

Appends a value to the end.

Warning
Triggers assertion if type mismatch and storage is not empty.
Template Parameters
TThe type of value (must match stored type)
Parameters
valueThe value to push

Definition at line 968 of file typed_buffer_array.hpp.

◆ rbegin() [1/2]

template<typename Allocator = std::allocator<std::byte>>
template<TypedBufferStorable T>
auto helios::container::TypedBufferArray< Allocator >::rbegin ( ) const -> std::reverse_iterator< const T * >
inlinenodiscardnoexcept

Returns const reverse iterator to the last element.

Template Parameters
TThe type of elements (must match stored type)
Returns
Const reverse iterator to the last element, or nullptr if no elements stored

Definition at line 636 of file typed_buffer_array.hpp.

◆ rbegin() [2/2]

template<typename Allocator = std::allocator<std::byte>>
template<TypedBufferStorable T>
auto helios::container::TypedBufferArray< Allocator >::rbegin ( ) -> std::reverse_iterator< T * >
inlinenodiscardnoexcept

Returns reverse iterator to the last element.

Template Parameters
TThe type of elements (must match stored type)
Returns
Reverse iterator to the last element, or nullptr if no elements stored

Definition at line 625 of file typed_buffer_array.hpp.

◆ rend() [1/2]

template<typename Allocator = std::allocator<std::byte>>
template<TypedBufferStorable T>
auto helios::container::TypedBufferArray< Allocator >::rend ( ) const -> std::reverse_iterator< const T * >
inlinenodiscardnoexcept

Returns const reverse iterator before the first element.

Template Parameters
TThe type of elements (must match stored type)
Returns
Const reverse iterator before the first element, or nullptr if no elements stored

Definition at line 671 of file typed_buffer_array.hpp.

◆ rend() [2/2]

template<typename Allocator = std::allocator<std::byte>>
template<TypedBufferStorable T>
auto helios::container::TypedBufferArray< Allocator >::rend ( ) -> std::reverse_iterator< T * >
inlinenodiscardnoexcept

Returns reverse iterator before the first element.

Template Parameters
TThe type of elements (must match stored type)
Returns
Reverse iterator before the first element, or nullptr if no elements stored

Definition at line 660 of file typed_buffer_array.hpp.

◆ Reserve()

template<typename Allocator>
void helios::container::TypedBufferArray< Allocator >::Reserve ( size_type count)
constexpr

Reserves space for at least the specified number of elements.

Warning
Triggers assertion if no type is set and count > 0.
Parameters
countNumber of elements to reserve space for

Definition at line 1197 of file typed_buffer_array.hpp.

◆ Reset()

template<typename Allocator>
void helios::container::TypedBufferArray< Allocator >::Reset ( )
constexprnoexcept

Resets storage to empty state with no associated type.

Destroys all elements and clears type information.

Definition at line 959 of file typed_buffer_array.hpp.

◆ Resize() [1/2]

template<typename Allocator>
requires std::default_initializable<T>
template<TypedBufferStorable T>
requires std::default_initializable<T>
void helios::container::TypedBufferArray< Allocator >::Resize ( size_type count)
inline

Resizes the storage to contain count elements (default-initialized).

Warning
Triggers assertion if type mismatch and storage is not empty.
Template Parameters
TThe type of elements (must match stored type)
Parameters
countNew size

Definition at line 1260 of file typed_buffer_array.hpp.

◆ Resize() [2/2]

template<typename Allocator>
requires std::copy_constructible<T>
template<TypedBufferStorable T>
requires std::copy_constructible<T>
void helios::container::TypedBufferArray< Allocator >::Resize ( size_type count,
const T & value )
inline

Resizes the storage to contain count elements.

Warning
Triggers assertion if type mismatch and storage is not empty.
Template Parameters
TThe type of elements (must match stored type)
Parameters
countNew size
valueValue to fill new elements with

Definition at line 1276 of file typed_buffer_array.hpp.

◆ ShrinkToFit()

template<typename Allocator>
void helios::container::TypedBufferArray< Allocator >::ShrinkToFit ( )
constexpr

Reduces capacity to fit the current size.

Definition at line 1230 of file typed_buffer_array.hpp.

◆ Size()

template<typename Allocator = std::allocator<std::byte>>
size_type helios::container::TypedBufferArray< Allocator >::Size ( ) const
inlinenodiscardconstexprnoexcept

Returns the number of stored elements.

Returns
Number of elements currently stored, or 0 if no type is set (even if bytes are present)

Definition at line 500 of file typed_buffer_array.hpp.

◆ SizeBytes()

template<typename Allocator = std::allocator<std::byte>>
size_type helios::container::TypedBufferArray< Allocator >::SizeBytes ( ) const
inlinenodiscardconstexprnoexcept

Returns the number of bytes occupied by stored elements.

Warning
If no type is set, this will return 0 even if there are bytes in the storage.

Definition at line 507 of file typed_buffer_array.hpp.

◆ StoredTypeId()

template<typename Allocator = std::allocator<std::byte>>
TypeIndex helios::container::TypedBufferArray< Allocator >::StoredTypeId ( ) const
inlinenodiscardconstexprnoexcept

Gets the current stored type index.

Returns
Type index of the stored type, or invalid index if no type is set

Definition at line 492 of file typed_buffer_array.hpp.

◆ Swap() [1/3]

template<typename Allocator>
template<TypedBufferStorable T>
void helios::container::TypedBufferArray< Allocator >::Swap ( size_type index,
size_type other_index )
inline

Swaps two elements within the buffer at the given indices (typed).

Uses std::swap.

Warning
Triggers assertion if storage has no type, stored type doesn't match T, or index >= Size().
Template Parameters
TThe type of stored elements (must match stored type)
Parameters
indexIndex of the first element
other_indexIndex of the second element

Definition at line 1514 of file typed_buffer_array.hpp.

◆ Swap() [2/3]

template<typename Allocator>
void helios::container::TypedBufferArray< Allocator >::Swap ( size_type index,
size_type other_index )
inline

Swaps two elements within the buffer at the given indices (type-erased).

For trivially copyable types, performs a direct byte-level swap. For non-trivially copyable types, performs a 3-step move-construct swap via temporary storage.

Warning
Triggers assertion if storage has no type, or index >= Size().
Parameters
indexIndex of the first element
other_indexIndex of the second element

Definition at line 1461 of file typed_buffer_array.hpp.

◆ Swap() [3/3]

template<typename Allocator>
void helios::container::TypedBufferArray< Allocator >::Swap ( TypedBufferArray< Allocator > & other)
constexprnoexcept

Swaps contents with another storage.

Parameters
otherStorage to swap with

Definition at line 1453 of file typed_buffer_array.hpp.

◆ TypeIndexOf()

template<typename Allocator = std::allocator<std::byte>>
template<TypedBufferStorable T>
consteval TypeIndex helios::container::TypedBufferArray< Allocator >::TypeIndexOf ( )
inlinestaticnodiscardconstevalnoexcept

Gets the type index for type T.

Template Parameters
TThe type to get index for
Returns
Type index

Definition at line 484 of file typed_buffer_array.hpp.

◆ swap

template<typename Allocator = std::allocator<std::byte>>
void swap ( TypedBufferArray< Allocator > & lhs,
TypedBufferArray< Allocator > & rhs )
friend

Definition at line 449 of file typed_buffer_array.hpp.

◆ TypedBufferArray

template<typename Allocator = std::allocator<std::byte>>
template<typename OtherA>
friend class TypedBufferArray
friend

Definition at line 688 of file typed_buffer_array.hpp.