11 using ValueType = uint32_t;
13 static constexpr uint32_t IndexBits = 24;
14 static constexpr uint32_t VersionBits = 8;
15 static constexpr ValueType IndexMask = (1u << IndexBits) - 1;
16 static constexpr ValueType VersionMask = (1u << VersionBits) - 1;
18 constexpr ID() noexcept
19 : m_Value(Invalid().m_Value)
22 constexpr ID(uint32_t index, uint32_t version) noexcept
23 : m_Value((version << IndexBits) | (index & IndexMask))
27 static constexpr ID Invalid()
noexcept
29 return ID(std::numeric_limits<ValueType>::max());
32 static constexpr ID FromRaw(ValueType raw)
noexcept
37 [[nodiscard]]
constexpr uint32_t Index()
const noexcept
39 return m_Value & IndexMask;
42 [[nodiscard]]
constexpr uint32_t Version()
const noexcept
44 return (m_Value >> IndexBits) & VersionMask;
47 [[nodiscard]]
constexpr ValueType Raw()
const noexcept
52 constexpr bool operator==(
const ID& other)
const noexcept =
default;
53 constexpr bool operator!=(
const ID& other)
const noexcept =
default;
55 constexpr explicit operator bool()
const noexcept
57 return m_Value != Invalid().m_Value;
61 explicit constexpr ID(ValueType raw) noexcept