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

Generic type-indexed map that stores one Storage instance per registered type key. More...

#include <multi_type_map.hpp>

Public Types

using TypeIndex = utils::TypeIndex
using size_type = size_t
using allocator_type = Allocator

Public Member Functions

constexpr MultiTypeMap ()=default
constexpr MultiTypeMap (const allocator_type &alloc)
 Constructs with a custom allocator.
constexpr MultiTypeMap (std::pmr::memory_resource *resource) noexcept(std::is_nothrow_constructible_v< allocator_type, std::pmr::memory_resource * >)
 Constructs with a PMR memory resource.
 MultiTypeMap (std::nullptr_t)=delete
constexpr MultiTypeMap (const MultiTypeMap &other)=default
constexpr MultiTypeMap (MultiTypeMap &&other) noexcept=default
constexpr ~MultiTypeMap ()=default
constexpr MultiTypeMapoperator= (const MultiTypeMap &other)=default
constexpr MultiTypeMapoperator= (MultiTypeMap &&other) noexcept=default
template<typename T>
constexpr void Clear () noexcept
 Clears the Storage for type T (calls Storage::Clear() or Storage::clear() if available).
constexpr void Clear (TypeIndex index) noexcept
 Clears the Storage for the given type index.
constexpr void ClearAll () noexcept
 Clears all per-type storages (calls Clear()/clear() on each entry if available).
template<typename T>
constexpr void Reset () noexcept
 Resets (removes) the Storage entry for type T.
constexpr void Reset (TypeIndex index) noexcept
 Resets (removes) the Storage entry for the given type index.
constexpr void ResetAll () noexcept
 Removes all Storage entries from the map.
template<typename T, typename... Args>
requires std::constructible_from<Storage, Args...>
constexpr auto Emplace (Args &&... args)
 Creates or replaces Storage for type T with the given value.
template<typename T, typename... Args>
requires std::constructible_from<Storage, Args...>
constexpr auto TryEmplace (Args &&... args)
 Creates Storage for type T with the given value, only if no entry for T already exists.
template<typename T>
constexpr bool Remove () noexcept
 Removes Storage for type T entirely.
constexpr bool Remove (TypeIndex index) noexcept
 Removes Storage for the given type index entirely.
template<typename T>
constexpr Storage & Ensure ()
 Ensures a Storage entry exists for type T and returns a reference to it.
constexpr Storage & Ensure (TypeIndex index)
 Ensures a Storage entry exists for the given type index and returns a reference to it.
template<typename T>
constexpr Storage & Get () noexcept
 Gets Storage for type T.
template<typename T>
constexpr const Storage & Get () const noexcept
 Gets Storage for type T (const).
constexpr Storage & Get (TypeIndex index) noexcept
 Gets Storage for the given type index.
constexpr const Storage & Get (TypeIndex index) const noexcept
 Gets Storage for the given type index (const).
template<typename T>
constexpr Storage * TryGet () noexcept
 Tries to get Storage for type T.
template<typename T>
constexpr const Storage * TryGet () const noexcept
 Tries to get Storage for type T (const).
constexpr Storage * TryGet (TypeIndex index) noexcept
 Tries to get Storage for the given type index.
constexpr const Storage * TryGet (TypeIndex index) const noexcept
 Tries to get Storage for the given type index (const).
template<typename OtherStorage, typename OtherAllocator>
constexpr void Merge (const MultiTypeMap< OtherStorage, OtherAllocator > &other)
 Merges all entries from another MultiTypeMap into this one.
template<typename OtherStorage, typename OtherAllocator>
constexpr void Merge (MultiTypeMap< OtherStorage, OtherAllocator > &&other)
constexpr void Swap (MultiTypeMap &other) noexcept(std::is_nothrow_swappable_v< MapType > &&std::is_nothrow_swappable_v< allocator_type >)
 Swaps contents with another MultiTypeMap.
template<typename T>
constexpr bool Contains () const noexcept
 Checks if a Storage entry exists for type T.
constexpr bool Contains (TypeIndex index) const noexcept
 Checks if a Storage entry exists for the given type index.
template<typename T>
constexpr bool Empty () const noexcept
 Checks if the Storage for type T is empty (no elements / no value).
constexpr bool Empty (TypeIndex index) const noexcept
 Checks if the Storage for the given type index is empty.
constexpr bool EmptyAll () const noexcept
 Returns true if all per-type storages are empty or if the map has no entries.
constexpr size_type Size () const noexcept
 Returns the total number of elements across all entries.
template<typename T>
constexpr size_type Size () const noexcept
 Returns the number of elements stored for type T.
constexpr size_type Size (TypeIndex index) const noexcept
 Returns the number of elements stored for the given type index.
constexpr size_type TypeCount () const noexcept
 Returns the number of registered type entries.
constexpr MapType & Data () noexcept
 Returns a view of the underlying map (non-const).
constexpr const MapType & Data () const noexcept
 Returns a view of the underlying map (const).
constexpr allocator_type GetAllocator () const noexcept
 Gets the allocator.
constexpr auto begin () noexcept
 Returns an iterator to the beginning of the map entries.
constexpr auto begin () const noexcept
 Returns a const iterator to the beginning of the map entries.
constexpr auto cbegin () const noexcept
 Returns a const iterator to the beginning of the map entries.
constexpr auto end () noexcept
 Returns an iterator to the end of the map entries.
constexpr auto end () const noexcept
 Returns a const iterator to the end of the map entries.
constexpr auto cend () const noexcept
 Returns a const iterator to the end of the map entries.

Static Public Member Functions

template<typename T>
static constexpr TypeIndex TypeIndexOf () noexcept
 Gets the compile-time type index for T.

Friends

template<typename OtherStorage, typename OtherA>
class MultiTypeMap
constexpr void swap (MultiTypeMap &lhs, MultiTypeMap &rhs) noexcept(std::is_nothrow_swappable_v< MapType > &&std::is_nothrow_swappable_v< allocator_type >)

Detailed Description

template<typename Storage, typename Allocator = std::allocator<std::byte>>
class helios::container::MultiTypeMap< Storage, Allocator >

Generic type-indexed map that stores one Storage instance per registered type key.

Uses a flat_map keyed by TypeIndex to store Storage instances. Each type gets its own storage entry identified by its compile-time type index. Type identification uses helios::utils::TypeIndex.

This class models a map structure — use Ensure<T>() / Get<T>() to obtain the underlying Storage and interact with individual entries directly.

If Storage supports ChangeType<T>(), it is called automatically on Ensure<T>(). If Storage supports Merge(Storage&&) or merge(Storage&&), it is called during Merge() for overlapping type entries.

Template Parameters
StorageThe value type stored per type key. Must be default-constructible.
AllocatorThe allocator type for the underlying flat_map (default: std::allocator<std::byte>)

Definition at line 45 of file multi_type_map.hpp.

Member Typedef Documentation

◆ allocator_type

template<typename Storage, typename Allocator = std::allocator<std::byte>>
using helios::container::MultiTypeMap< Storage, Allocator >::allocator_type = Allocator

Definition at line 50 of file multi_type_map.hpp.

◆ size_type

template<typename Storage, typename Allocator = std::allocator<std::byte>>
using helios::container::MultiTypeMap< Storage, Allocator >::size_type = size_t

Definition at line 49 of file multi_type_map.hpp.

◆ TypeIndex

template<typename Storage, typename Allocator = std::allocator<std::byte>>
using helios::container::MultiTypeMap< Storage, Allocator >::TypeIndex = utils::TypeIndex

Definition at line 47 of file multi_type_map.hpp.

Constructor & Destructor Documentation

◆ MultiTypeMap() [1/6]

template<typename Storage, typename Allocator = std::allocator<std::byte>>
helios::container::MultiTypeMap< Storage, Allocator >::MultiTypeMap ( )
constexprdefault

◆ MultiTypeMap() [2/6]

template<typename Storage, typename Allocator = std::allocator<std::byte>>
helios::container::MultiTypeMap< Storage, Allocator >::MultiTypeMap ( const allocator_type & alloc)
inlineexplicitconstexpr

Constructs with a custom allocator.

Parameters
allocAllocator instance to use

Definition at line 88 of file multi_type_map.hpp.

◆ MultiTypeMap() [3/6]

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

Constructs with 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 98 of file multi_type_map.hpp.

◆ MultiTypeMap() [4/6]

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

◆ MultiTypeMap() [5/6]

template<typename Storage, typename Allocator = std::allocator<std::byte>>
helios::container::MultiTypeMap< Storage, Allocator >::MultiTypeMap ( const MultiTypeMap< Storage, Allocator > & other)
constexprdefault

◆ MultiTypeMap() [6/6]

template<typename Storage, typename Allocator = std::allocator<std::byte>>
helios::container::MultiTypeMap< Storage, Allocator >::MultiTypeMap ( MultiTypeMap< Storage, Allocator > && other)
constexprdefaultnoexcept

◆ ~MultiTypeMap()

template<typename Storage, typename Allocator = std::allocator<std::byte>>
helios::container::MultiTypeMap< Storage, Allocator >::~MultiTypeMap ( )
constexprdefault

Member Function Documentation

◆ begin() [1/2]

template<typename Storage, typename Allocator = std::allocator<std::byte>>
auto helios::container::MultiTypeMap< Storage, Allocator >::begin ( ) const
inlinenodiscardconstexprnoexcept

Returns a const iterator to the beginning of the map entries.

Returns
Const iterator to the beginning of the map entries

Definition at line 457 of file multi_type_map.hpp.

◆ begin() [2/2]

template<typename Storage, typename Allocator = std::allocator<std::byte>>
auto helios::container::MultiTypeMap< Storage, Allocator >::begin ( )
inlinenodiscardconstexprnoexcept

Returns an iterator to the beginning of the map entries.

Returns
Iterator to the beginning of the map entries

Definition at line 451 of file multi_type_map.hpp.

◆ cbegin()

template<typename Storage, typename Allocator = std::allocator<std::byte>>
auto helios::container::MultiTypeMap< Storage, Allocator >::cbegin ( ) const
inlinenodiscardconstexprnoexcept

Returns a const iterator to the beginning of the map entries.

Returns
Const iterator to the beginning of the map entries

Definition at line 465 of file multi_type_map.hpp.

◆ cend()

template<typename Storage, typename Allocator = std::allocator<std::byte>>
auto helios::container::MultiTypeMap< Storage, Allocator >::cend ( ) const
inlinenodiscardconstexprnoexcept

Returns a const iterator to the end of the map entries.

Returns
Const iterator to the end of the map entries

Definition at line 485 of file multi_type_map.hpp.

◆ Clear() [1/2]

template<typename Storage, typename Allocator = std::allocator<std::byte>>
template<typename T>
void helios::container::MultiTypeMap< Storage, Allocator >::Clear ( )
inlineconstexprnoexcept

Clears the Storage for type T (calls Storage::Clear() or Storage::clear() if available).

Template Parameters
TThe type key to clear

Definition at line 119 of file multi_type_map.hpp.

◆ Clear() [2/2]

template<typename Storage, typename Allocator>
void helios::container::MultiTypeMap< Storage, Allocator >::Clear ( TypeIndex index)
constexprnoexcept

Clears the Storage for the given type index.

Parameters
indexThe type index to clear

Definition at line 500 of file multi_type_map.hpp.

◆ ClearAll()

template<typename Storage, typename Allocator>
void helios::container::MultiTypeMap< Storage, Allocator >::ClearAll ( )
constexprnoexcept

Clears all per-type storages (calls Clear()/clear() on each entry if available).

Definition at line 512 of file multi_type_map.hpp.

◆ Contains() [1/2]

template<typename Storage, typename Allocator = std::allocator<std::byte>>
template<typename T>
bool helios::container::MultiTypeMap< Storage, Allocator >::Contains ( ) const
inlinenodiscardconstexprnoexcept

Checks if a Storage entry exists for type T.

Template Parameters
TThe type key to check
Returns
true if an entry exists

Definition at line 340 of file multi_type_map.hpp.

◆ Contains() [2/2]

template<typename Storage, typename Allocator = std::allocator<std::byte>>
bool helios::container::MultiTypeMap< Storage, Allocator >::Contains ( TypeIndex index) const
inlinenodiscardconstexprnoexcept

Checks if a Storage entry exists for the given type index.

Parameters
indexThe type index to check
Returns
true if an entry exists

Definition at line 349 of file multi_type_map.hpp.

◆ Data() [1/2]

template<typename Storage, typename Allocator = std::allocator<std::byte>>
const MapType & helios::container::MultiTypeMap< Storage, Allocator >::Data ( ) const
inlinenodiscardconstexprnoexcept

Returns a view of the underlying map (const).

Returns
Const reference to the underlying flat_map

Definition at line 435 of file multi_type_map.hpp.

◆ Data() [2/2]

template<typename Storage, typename Allocator = std::allocator<std::byte>>
MapType & helios::container::MultiTypeMap< Storage, Allocator >::Data ( )
inlinenodiscardconstexprnoexcept

Returns a view of the underlying map (non-const).

Returns
Reference to the underlying flat_map

Definition at line 429 of file multi_type_map.hpp.

◆ Emplace()

template<typename Storage, typename Allocator = std::allocator<std::byte>>
template<typename T, typename... Args>
requires std::constructible_from<Storage, Args...>
auto helios::container::MultiTypeMap< Storage, Allocator >::Emplace ( Args &&... args)
inlineconstexpr

Creates or replaces Storage for type T with the given value.

The type key is derived from T

Template Parameters
TThe type key — TypeIndexOf<T> is used as the map key
ArgsThe argument types for constructing Storage
Parameters
argsThe arguments to construct the Storage value (perfect-forwarded)
Returns
Pair of iterator to the entry and bool — true if a new entry was inserted

Definition at line 163 of file multi_type_map.hpp.

◆ Empty() [1/2]

template<typename Storage, typename Allocator = std::allocator<std::byte>>
template<typename T>
bool helios::container::MultiTypeMap< Storage, Allocator >::Empty ( ) const
inlinenodiscardconstexprnoexcept

Checks if the Storage for type T is empty (no elements / no value).

Returns true if the entry doesn't exist, or if Storage supports Empty()/empty() and it returns true.

Template Parameters
TThe type key to check
Returns
true if storage is empty or doesn't exist

Definition at line 362 of file multi_type_map.hpp.

◆ Empty() [2/2]

template<typename Storage, typename Allocator>
bool helios::container::MultiTypeMap< Storage, Allocator >::Empty ( TypeIndex index) const
nodiscardconstexprnoexcept

Checks if the Storage for the given type index is empty.

Parameters
indexThe type index to check
Returns
true if storage is empty or doesn't exist

Definition at line 707 of file multi_type_map.hpp.

◆ EmptyAll()

template<typename Storage, typename Allocator>
bool helios::container::MultiTypeMap< Storage, Allocator >::EmptyAll ( ) const
nodiscardconstexprnoexcept

Returns true if all per-type storages are empty or if the map has no entries.

Returns
true if all storages are empty

Definition at line 723 of file multi_type_map.hpp.

◆ end() [1/2]

template<typename Storage, typename Allocator = std::allocator<std::byte>>
auto helios::container::MultiTypeMap< Storage, Allocator >::end ( ) const
inlinenodiscardconstexprnoexcept

Returns a const iterator to the end of the map entries.

Returns
Const iterator to the end of the map entries

Definition at line 479 of file multi_type_map.hpp.

◆ end() [2/2]

template<typename Storage, typename Allocator = std::allocator<std::byte>>
auto helios::container::MultiTypeMap< Storage, Allocator >::end ( )
inlinenodiscardconstexprnoexcept

Returns an iterator to the end of the map entries.

Returns
Iterator to the end of the map entries

Definition at line 473 of file multi_type_map.hpp.

◆ Ensure() [1/2]

template<typename Storage, typename Allocator>
template<typename T>
Storage & helios::container::MultiTypeMap< Storage, Allocator >::Ensure ( )
constexpr

Ensures a Storage entry exists for type T and returns a reference to it.

If no entry exists for T, a new default-constructed Storage is inserted. If Storage supports ChangeType<T>(), it is called on the newly created entry.

Template Parameters
TThe type key to ensure storage for
Returns
Reference to the Storage for type T

Definition at line 524 of file multi_type_map.hpp.

◆ Ensure() [2/2]

template<typename Storage, typename Allocator>
Storage & helios::container::MultiTypeMap< Storage, Allocator >::Ensure ( TypeIndex index)
constexpr

Ensures a Storage entry exists for the given type index and returns a reference to it.

If no entry exists, a new default-constructed Storage is inserted.

Parameters
indexThe type index to ensure storage for
Returns
Reference to the Storage for the given type index

Definition at line 538 of file multi_type_map.hpp.

◆ Get() [1/4]

template<typename Storage, typename Allocator>
template<typename T>
const Storage & helios::container::MultiTypeMap< Storage, Allocator >::Get ( ) const
nodiscardconstexprnoexcept

Gets Storage for type T (const).

Warning
Triggers assertion if storage for type T doesn't exist.
Template Parameters
TThe type key to get storage for
Returns
Const reference to the Storage for type T

Definition at line 562 of file multi_type_map.hpp.

◆ Get() [2/4]

template<typename Storage, typename Allocator>
template<typename T>
Storage & helios::container::MultiTypeMap< Storage, Allocator >::Get ( )
nodiscardconstexprnoexcept

Gets Storage for type T.

Warning
Triggers assertion if storage for type T doesn't exist.
Template Parameters
TThe type key to get storage for
Returns
Reference to the Storage for type T

Definition at line 552 of file multi_type_map.hpp.

◆ Get() [3/4]

template<typename Storage, typename Allocator>
const Storage & helios::container::MultiTypeMap< Storage, Allocator >::Get ( TypeIndex index) const
nodiscardconstexprnoexcept

Gets Storage for the given type index (const).

Warning
Triggers assertion if storage for the given type index doesn't exist.
Parameters
indexThe type index to get storage for
Returns
Const reference to the Storage for the given type index

Definition at line 581 of file multi_type_map.hpp.

◆ Get() [4/4]

template<typename Storage, typename Allocator>
Storage & helios::container::MultiTypeMap< Storage, Allocator >::Get ( TypeIndex index)
nodiscardconstexprnoexcept

Gets Storage for the given type index.

Warning
Triggers assertion if storage for the given type index doesn't exist.
Parameters
indexThe type index to get storage for
Returns
Reference to the Storage for the given type index

Definition at line 572 of file multi_type_map.hpp.

◆ GetAllocator()

template<typename Storage, typename Allocator = std::allocator<std::byte>>
allocator_type helios::container::MultiTypeMap< Storage, Allocator >::GetAllocator ( ) const
inlinenodiscardconstexprnoexcept

Gets the allocator.

Returns
Copy of the allocator

Definition at line 443 of file multi_type_map.hpp.

◆ Merge() [1/2]

template<typename Storage, typename Allocator>
template<typename OtherStorage, typename OtherAllocator>
void helios::container::MultiTypeMap< Storage, Allocator >::Merge ( const MultiTypeMap< OtherStorage, OtherAllocator > & other)
constexpr

Merges all entries from another MultiTypeMap into this one.

For each entry in other:

  • If this map already contains the same type key, calls Storage::Merge or Storage::merge on the existing entry if such a method is available.
  • Otherwise, the entry from other is inserted into this map. For differing Storage types, a new default Storage is created and Merge/merge is attempted on it.

After merging, other is fully cleared (TypeCount() == 0).

Template Parameters
OtherStorageStorage type of the other map (may differ from Storage)
OtherAllocatorThe allocator template of the other map
Parameters
otherThe map to merge from

Definition at line 605 of file multi_type_map.hpp.

◆ Merge() [2/2]

template<typename Storage, typename Allocator>
template<typename OtherStorage, typename OtherAllocator>
void helios::container::MultiTypeMap< Storage, Allocator >::Merge ( MultiTypeMap< OtherStorage, OtherAllocator > && other)
constexpr

Definition at line 666 of file multi_type_map.hpp.

◆ operator=() [1/2]

template<typename Storage, typename Allocator = std::allocator<std::byte>>
MultiTypeMap & helios::container::MultiTypeMap< Storage, Allocator >::operator= ( const MultiTypeMap< Storage, Allocator > & other)
constexprdefault

◆ operator=() [2/2]

template<typename Storage, typename Allocator = std::allocator<std::byte>>
MultiTypeMap & helios::container::MultiTypeMap< Storage, Allocator >::operator= ( MultiTypeMap< Storage, Allocator > && other)
constexprdefaultnoexcept

◆ Remove() [1/2]

template<typename Storage, typename Allocator = std::allocator<std::byte>>
template<typename T>
bool helios::container::MultiTypeMap< Storage, Allocator >::Remove ( )
inlineconstexprnoexcept

Removes Storage for type T entirely.

Template Parameters
TThe type key to remove
Returns
true if storage was removed

Definition at line 191 of file multi_type_map.hpp.

◆ Remove() [2/2]

template<typename Storage, typename Allocator = std::allocator<std::byte>>
bool helios::container::MultiTypeMap< Storage, Allocator >::Remove ( TypeIndex index)
inlineconstexprnoexcept

Removes Storage for the given type index entirely.

Parameters
indexThe type index to remove
Returns
true if storage was removed

Definition at line 200 of file multi_type_map.hpp.

◆ Reset() [1/2]

template<typename Storage, typename Allocator = std::allocator<std::byte>>
template<typename T>
void helios::container::MultiTypeMap< Storage, Allocator >::Reset ( )
inlineconstexprnoexcept

Resets (removes) the Storage entry for type T.

Template Parameters
TThe type key to reset

Definition at line 138 of file multi_type_map.hpp.

◆ Reset() [2/2]

template<typename Storage, typename Allocator = std::allocator<std::byte>>
void helios::container::MultiTypeMap< Storage, Allocator >::Reset ( TypeIndex index)
inlineconstexprnoexcept

Resets (removes) the Storage entry for the given type index.

Parameters
indexThe type index to reset

Definition at line 146 of file multi_type_map.hpp.

◆ ResetAll()

template<typename Storage, typename Allocator = std::allocator<std::byte>>
void helios::container::MultiTypeMap< Storage, Allocator >::ResetAll ( )
inlineconstexprnoexcept

Removes all Storage entries from the map.

Definition at line 149 of file multi_type_map.hpp.

◆ Size() [1/3]

template<typename Storage, typename Allocator = std::allocator<std::byte>>
template<typename T>
size_type helios::container::MultiTypeMap< Storage, Allocator >::Size ( ) const
inlinenodiscardconstexprnoexcept

Returns the number of elements stored for type T.

Returns Storage::Size() or Storage::size() if available, else 0 if entry exists.

Template Parameters
TThe type key to query
Returns
Element count, 0 if storage doesn't exist

Definition at line 406 of file multi_type_map.hpp.

◆ Size() [2/3]

template<typename Storage, typename Allocator>
auto helios::container::MultiTypeMap< Storage, Allocator >::Size ( ) const
nodiscardconstexprnoexcept

Returns the total number of elements across all entries.

Only meaningful if Storage supports Size() or size(). Returns number of map entries otherwise.

Returns
Total element count (or entry count if Storage has no size method)

Definition at line 736 of file multi_type_map.hpp.

◆ Size() [3/3]

template<typename Storage, typename Allocator>
auto helios::container::MultiTypeMap< Storage, Allocator >::Size ( TypeIndex index) const
nodiscardconstexprnoexcept

Returns the number of elements stored for the given type index.

Parameters
indexThe type index to query
Returns
Element count, 0 if storage doesn't exist

Definition at line 752 of file multi_type_map.hpp.

◆ Swap()

template<typename Storage, typename Allocator = std::allocator<std::byte>>
void helios::container::MultiTypeMap< Storage, Allocator >::Swap ( MultiTypeMap< Storage, Allocator > & other)
inlineconstexprnoexcept

Swaps contents with another MultiTypeMap.

Parameters
otherMap to swap with

Definition at line 321 of file multi_type_map.hpp.

◆ TryEmplace()

template<typename Storage, typename Allocator = std::allocator<std::byte>>
template<typename T, typename... Args>
requires std::constructible_from<Storage, Args...>
auto helios::container::MultiTypeMap< Storage, Allocator >::TryEmplace ( Args &&... args)
inlineconstexpr

Creates Storage for type T with the given value, only if no entry for T already exists.

The type key is derived from T Unlike Emplace, this never overwrites an existing entry.

Template Parameters
TThe type key — TypeIndexOf<T> is used as the map key
ArgsThe argument types for constructing Storage
Parameters
argsThe arguments to construct the Storage value (perfect-forwarded)
Returns
Pair of iterator to the entry and bool — true if a new entry was inserted

Definition at line 181 of file multi_type_map.hpp.

◆ TryGet() [1/4]

template<typename Storage, typename Allocator = std::allocator<std::byte>>
template<typename T>
const Storage * helios::container::MultiTypeMap< Storage, Allocator >::TryGet ( ) const
inlinenodiscardconstexprnoexcept

Tries to get Storage for type T (const).

Template Parameters
TThe type key to get storage for
Returns
Const pointer to Storage if exists, nullptr otherwise

Definition at line 277 of file multi_type_map.hpp.

◆ TryGet() [2/4]

template<typename Storage, typename Allocator = std::allocator<std::byte>>
template<typename T>
Storage * helios::container::MultiTypeMap< Storage, Allocator >::TryGet ( )
inlinenodiscardconstexprnoexcept

Tries to get Storage for type T.

Template Parameters
TThe type key to get storage for
Returns
Pointer to Storage if exists, nullptr otherwise

Definition at line 267 of file multi_type_map.hpp.

◆ TryGet() [3/4]

template<typename Storage, typename Allocator>
const Storage * helios::container::MultiTypeMap< Storage, Allocator >::TryGet ( TypeIndex index) const
nodiscardconstexprnoexcept

Tries to get Storage for the given type index (const).

Parameters
indexThe type index to get storage for
Returns
Const pointer to Storage if exists, nullptr otherwise

Definition at line 597 of file multi_type_map.hpp.

◆ TryGet() [4/4]

template<typename Storage, typename Allocator>
Storage * helios::container::MultiTypeMap< Storage, Allocator >::TryGet ( TypeIndex index)
nodiscardconstexprnoexcept

Tries to get Storage for the given type index.

Parameters
indexThe type index to get storage for
Returns
Pointer to Storage if exists, nullptr otherwise

Definition at line 590 of file multi_type_map.hpp.

◆ TypeCount()

template<typename Storage, typename Allocator = std::allocator<std::byte>>
size_type helios::container::MultiTypeMap< Storage, Allocator >::TypeCount ( ) const
inlinenodiscardconstexprnoexcept

Returns the number of registered type entries.

Returns
Number of registered type entries

Definition at line 421 of file multi_type_map.hpp.

◆ TypeIndexOf()

template<typename Storage, typename Allocator = std::allocator<std::byte>>
template<typename T>
constexpr TypeIndex helios::container::MultiTypeMap< Storage, Allocator >::TypeIndexOf ( )
inlinestaticnodiscardconstexprnoexcept

Gets the compile-time type index for T.

Template Parameters
TThe type to get index for
Returns
Type index

Definition at line 386 of file multi_type_map.hpp.

◆ MultiTypeMap

template<typename Storage, typename Allocator = std::allocator<std::byte>>
template<typename OtherStorage, typename OtherA>
friend class MultiTypeMap
friend

Definition at line 489 of file multi_type_map.hpp.

◆ swap

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

Definition at line 328 of file multi_type_map.hpp.