4#include <entt/entt.hpp>
18template <
typename TDerived,
typename TValue>
struct BasicId {
28 constexpr explicit(
false)
BasicId(TValue v = TDerived::NullValue()) :
value{v} {}
34 static constexpr TDerived Null() {
return TDerived::Null(); }
39 constexpr bool IsNull()
const {
return value == TDerived::NullValue(); }
77static_assert(
sizeof(Id) ==
sizeof(
Id::ValueType),
"Id size must be equal to entt::id_type size");
114 "StringId size must be equal to entt::hashed_string size");
121template <>
struct entt::entt_traits<
Engine::Id> : entt::entt_traits<entt::id_type> {
126template <>
struct fmt::formatter<
Engine::Id> : fmt::formatter<entt::id_type> {
134 template <
typename FormatContext>
auto format(
const Engine::Id &
id, FormatContext &ctx)
const
136 return fmt::formatter<entt::id_type>::format(
id.value, ctx);
144template <>
struct fmt::formatter<
Engine::StringId> : fmt::formatter<std::string_view> {
155 return fmt::formatter<std::string_view>::format(std::string_view(
id.value.data(),
id.value.size()), ctx);
An Id class for creating strongly-typed ID wrappers. This template provides a common interface for ID...
Definition Id.hpp:18
TValue value
The underlying value of the ID.
Definition Id.hpp:20
A strongly-typed identifier wrapper based on entt::id_type. This structure provides a type-safe wrapp...
Definition Id.hpp:49
static constexpr ValueType NullValue()
Get the null value for this ID type. This returns the null value defined by EnTT's id_type,...
Definition Id.hpp:66
constexpr Id(ValueType v=NullValue())
Constructor for Id.
Definition Id.hpp:56
static constexpr Id Null()
Get a null instance of Id, which has its value set to the null value defined by NullValue().
Definition Id.hpp:71
entt::id_type ValueType
Definition Id.hpp:50
Static assertion to ensure that the size of Id matches the size of entt::id_type, guaranteeing that t...
Definition Id.hpp:88
static constexpr ValueType NullValue()
Get the null value for this StringId type. This returns a default-constructed entt::hashed_string.
Definition Id.hpp:103
static constexpr StringId Null()
Get a null instance of StringId, which has its value set to the null value defined by NullValue().
Definition Id.hpp:108
constexpr StringId(ValueType v=NullValue())
Constructor for StringId.
Definition Id.hpp:98
entt::hashed_string ValueType
The underlying value type for StringId, which is entt::hashed_string. This type encapsulates the stri...
Definition Id.hpp:92
Engine::Id value_type
Definition Id.hpp:122