Skip to main content

StrongId Struct Template

A strongly-typed identifier using tag-based type safety. More...

Declaration

template <typename Tag, typename Underlying = uint32_t> struct helios::core::data::StrongId<Tag, Underlying> { ... }

Friends Index

template <typename Tag, typename Underlying = uint32_t>
booloperator==

Equality comparison. More...

Public Constructors Index

template <typename Tag, typename Underlying = uint32_t>
constexprStrongId (const std::string_view str) noexcept

Constructs from a compile-time string. More...

template <typename Tag, typename Underlying = uint32_t>
constexprStrongId (helios::core::types::no_init_t)

Constructs an uninitialized ID. More...

template <typename Tag, typename Underlying = uint32_t>
constexprStrongId ()

Default constructor creating an uninitialized ID. More...

Private Constructors Index

template <typename Tag, typename Underlying = uint32_t>
constexprStrongId (const Underlying id) noexcept

Constructs from a raw underlying value. More...

Public Operators Index

template <typename Tag, typename Underlying = uint32_t>
operator bool () const noexcept

Checks if the ID is valid (non-zero). More...

template <typename Tag, typename Underlying = uint32_t>
constexpr booloperator< (const StrongId &other) const noexcept

Less-than comparison for ordering. More...

template <typename Tag, typename Underlying = uint32_t>
constexpr booloperator> (const StrongId &other) const noexcept

Greater-than comparison for ordering. More...

Public Member Functions Index

template <typename Tag, typename Underlying = uint32_t>
Underlyingvalue () const noexcept

Returns the underlying ID value. More...

Private Member Attributes Index

template <typename Tag, typename Underlying = uint32_t>
Underlyingid_ {}

The underlying ID value. More...

Description

A strongly-typed identifier using tag-based type safety.

Provides compile-time type safety for identifiers by associating each ID type with a unique tag struct. Supports compile-time string hashing via FNV-1a algorithm.

Template Parameters
Tag

Empty struct used to distinguish different ID types.

Underlying

The underlying integral type (default: uint32_t).

Definition at line 28 of file StrongId.ixx.

Friends

operator==

friend bool StrongId, StrongId
constexpr noexcept default

Equality comparison.

Definition at line 92 of file StrongId.ixx.

Public Constructors

StrongId()

template <typename Tag, typename Underlying = uint32_t>
helios::core::data::StrongId< Tag, Underlying >::StrongId (const std::string_view str)
inline explicit constexpr noexcept

Constructs from a compile-time string.

Uses FNV-1a hashing to convert the string to an ID.

Parameters
str

The string to hash.

Definition at line 56 of file StrongId.ixx.

56 explicit constexpr StrongId(const std::string_view str) noexcept

StrongId()

template <typename Tag, typename Underlying = uint32_t>
helios::core::data::StrongId< Tag, Underlying >::StrongId (helios::core::types::no_init_t)
inline explicit constexpr

Constructs an uninitialized ID.

Parameters
no_init_t

Tag type indicating no initialization.

Definition at line 64 of file StrongId.ixx.

StrongId()

template <typename Tag, typename Underlying = uint32_t>
helios::core::data::StrongId< Tag, Underlying >::StrongId ()
inline explicit constexpr

Default constructor creating an uninitialized ID.

Definition at line 69 of file StrongId.ixx.

69 explicit constexpr StrongId() : StrongId(helios::core::types::no_init){};

Private Constructors

StrongId()

template <typename Tag, typename Underlying = uint32_t>
helios::core::data::StrongId< Tag, Underlying >::StrongId (const Underlying id)
inline explicit constexpr noexcept

Constructs from a raw underlying value.

Parameters
id

The raw ID value.

Definition at line 43 of file StrongId.ixx.

43 explicit constexpr StrongId(const Underlying id) noexcept
44 : id_(id) {
45 }

Public Operators

operator bool()

template <typename Tag, typename Underlying = uint32_t>
helios::core::data::StrongId< Tag, Underlying >::operator bool ()
inline explicit nodiscard noexcept

Checks if the ID is valid (non-zero).

Returns

True if the ID is non-zero.

Definition at line 85 of file StrongId.ixx.

85 [[nodiscard]] explicit operator bool() const noexcept {
86 return id_ != 0;
87 }

operator<()

template <typename Tag, typename Underlying = uint32_t>
bool helios::core::data::StrongId< Tag, Underlying >::operator< (const StrongId & other)
inline constexpr noexcept

Less-than comparison for ordering.

Parameters
other

The other ID to compare.

Returns

True if this ID is less than the other.

Definition at line 101 of file StrongId.ixx.

101 constexpr bool operator<(const StrongId& other) const noexcept {
102 return id_ < other.id_;
103 }

operator>()

template <typename Tag, typename Underlying = uint32_t>
bool helios::core::data::StrongId< Tag, Underlying >::operator> (const StrongId & other)
inline constexpr noexcept

Greater-than comparison for ordering.

Parameters
other

The other ID to compare.

Returns

True if this ID is greater than the other.

Definition at line 112 of file StrongId.ixx.

112 constexpr bool operator>(const StrongId& other) const noexcept {
113 return id_ > other.id_;
114 }

Public Member Functions

value()

template <typename Tag, typename Underlying = uint32_t>
Underlying helios::core::data::StrongId< Tag, Underlying >::value ()
inline nodiscard noexcept

Returns the underlying ID value.

Returns

The raw underlying value.

Definition at line 76 of file StrongId.ixx.

76 [[nodiscard]] Underlying value() const noexcept {
77 return id_;
78 }

Private Member Attributes

id_

template <typename Tag, typename Underlying = uint32_t>
Underlying helios::core::data::StrongId< Tag, Underlying >::id_ {}

The underlying ID value.

Definition at line 36 of file StrongId.ixx.

36 Underlying id_{};

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.