Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
Engine::BasicId< TDerived, TValue > Struct Template Reference

An Id class for creating strongly-typed ID wrappers. This template provides a common interface for ID types by wrapping a value type with type-safe operations. Derived classes should implement static NullValue() and Null() methods to define null/invalid ID semantics. More...

#include <Id.hpp>

Public Member Functions

constexpr bool IsNull (void) const
 Checks if the ID is null/invalid by comparing its value to the null value defined by the derived class.

Static Public Member Functions

static constexpr TDerived Null (void)
 Get the null value for this ID type. This should be defined by the derived class to specify what constitutes a null/invalid ID.

Public Attributes

TValue value
 The underlying value of the ID.

Private Member Functions

constexpr explicit (false) BasicId(TValue value_
 Constructor for BasicId. Allows implicit construction from the underlying value type, defaulting to the null value.

Private Attributes

friend TDerived

Detailed Description

template<typename TDerived, typename TValue>
struct Engine::BasicId< TDerived, TValue >

An Id class for creating strongly-typed ID wrappers. This template provides a common interface for ID types by wrapping a value type with type-safe operations. Derived classes should implement static NullValue() and Null() methods to define null/invalid ID semantics.

Template Parameters
TDerivedThe derived class type (CRTP pattern)
TValueThe underlying value type for the ID (e.g., int, uint64_t, etc.)
Note
Derived classes must provide:
  • static constexpr TValue NullValue() - Returns the value representing a null/invalid ID
  • static constexpr TDerived Null() - Returns a null instance of the derived type

Member Function Documentation

◆ explicit()

template<typename TDerived, typename TValue>
Engine::BasicId< TDerived, TValue >::explicit ( false )
constexprprivate

Constructor for BasicId. Allows implicit construction from the underlying value type, defaulting to the null value.

Parameters
value_The value to initialize the ID with. Defaults to the null value defined by the derived class.
Returns
An instance of the derived ID type initialized with the given value.

◆ IsNull()

template<typename TDerived, typename TValue>
bool Engine::BasicId< TDerived, TValue >::IsNull ( void ) const
constexpr

Checks if the ID is null/invalid by comparing its value to the null value defined by the derived class.

Returns
True if the ID is null/invalid, false otherwise.

◆ Null()

template<typename TDerived, typename TValue>
TDerived Engine::BasicId< TDerived, TValue >::Null ( void )
staticconstexpr

Get the null value for this ID type. This should be defined by the derived class to specify what constitutes a null/invalid ID.

Returns
The value representing a null/invalid ID for this type.

Member Data Documentation

◆ TDerived

template<typename TDerived, typename TValue>
friend Engine::BasicId< TDerived, TValue >::TDerived
private

◆ value

template<typename TDerived, typename TValue>
TValue Engine::BasicId< TDerived, TValue >::value

The underlying value of the ID.


The documentation for this struct was generated from the following files: