LeviLamina
Loading...
Searching...
No Matches
AutomaticID.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5template <typename A, typename T>
7public:
8 T id;
9
10 using Type = A;
11
12 [[nodiscard]] constexpr AutomaticID() : id(0) {}
13
14 [[nodiscard]] constexpr AutomaticID(T x) : id(x) {}
15
16 [[nodiscard]] constexpr operator T() const { return id; }
17
18 [[nodiscard]] inline bool operator==(AutomaticID const& other) const { return id == other.id; }
19
20 [[nodiscard]] inline bool operator==(T const& other) const { return id == other; }
21
22 [[nodiscard]] inline std::strong_ordering operator<=>(AutomaticID const& other) const { return id <=> other.id; }
23
24 [[nodiscard]] inline std::strong_ordering operator<=>(T const& other) const { return id <=> other; }
25};
26
27namespace std {
28template <typename A, typename T>
29class hash<AutomaticID<A, T>> {
30public:
31 size_t operator()(AutomaticID<A, T> const& dimId) const { return static_cast<size_t>(dimId.id); }
32};
33} // namespace std
Definition AutomaticID.h:6
STL namespace.