23 #ifndef ETCPAL_CPP_OPAQUE_ID_H_
24 #define ETCPAL_CPP_OPAQUE_ID_H_
116 template <
class IdType,
class ValueType, ValueType Inval
idValue>
125 constexpr ValueType
value()
const;
126 constexpr
bool IsValid()
const;
127 constexpr
explicit operator bool()
const;
134 ValueType value_{InvalidValue};
145 template <
class IdType,
class ValueType, ValueType Inval
idValue>
152 template <
class IdType,
class ValueType, ValueType Inval
idValue>
158 template <
class IdType,
class ValueType, ValueType Inval
idValue>
165 template <
class IdType,
class ValueType, ValueType Inval
idValue>
168 return !(value_ == InvalidValue);
184 template <
class IdType,
class ValueType, ValueType Inval
idValue>
191 template <
class IdType,
class ValueType, ValueType Inval
idValue>
199 template <
class IdType,
class ValueType, ValueType Inval
idValue>
207 template <
class IdType,
class ValueType, ValueType Inval
idValue>
210 value_ = InvalidValue;
219 template <
class IdType,
class ValueType, ValueType Inval
idValue>
226 template <
class IdType,
class ValueType, ValueType Inval
idValue>
227 constexpr
bool operator!=(
const OpaqueId<IdType, ValueType, InvalidValue>& a,
228 const OpaqueId<IdType, ValueType, InvalidValue>& b)
246 template <
class IdType,
class ValueType, ValueType Inval
idValue>
249 ETCPAL_CONSTEXPR_14 bool operator()(const ::etcpal::OpaqueId<IdType, ValueType, InvalidValue>& a,
250 const ::etcpal::OpaqueId<IdType, ValueType, InvalidValue>& b)
const
252 return a.value() < b.value();
263 template <
class IdType,
class ValueType, ValueType Inval
idValue>
266 std::size_t operator()(const ::etcpal::OpaqueId<IdType, ValueType, InvalidValue>&
id)
const noexcept
268 return std::hash<ValueType>()(
id.value());
A strongly-typed ID with arbitrary internal representation.
Definition: opaque_id.h:118
static constexpr OpaqueId Invalid()
Explicitly create an invalid ID.
Definition: opaque_id.h:146
ETCPAL_CONSTEXPR_14 void Clear()
Clear any valid value from an ID and set it back to the invalid value.
Definition: opaque_id.h:208
ETCPAL_CONSTEXPR_14 void SetValue(const ValueType &new_value)
Set a new underlying value for an ID.
Definition: opaque_id.h:200
constexpr bool IsValid() const
Explicitly determine whether an ID is valid.
Definition: opaque_id.h:166
constexpr bool operator!() const
Determine whether an ID is not valid.
Definition: opaque_id.h:192
constexpr ValueType value() const
Get the underlying value from an ID.
Definition: opaque_id.h:159
Common definitions used by EtcPal C++ wrappers.
#define ETCPAL_CONSTEXPR_14
Stand-in for "constexpr" on entities that can only be defined "constexpr" in C++14 or later.
Definition: common.h:53
#define ETCPAL_CONSTEXPR_14_OR_INLINE
Defined to "constexpr" in C++14 or later, "inline" earlier.
Definition: common.h:54