Some small changes. (#20)
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <algorithm>
|
||||
#include <string_view>
|
||||
#include <source_location>
|
||||
|
||||
@@ -240,6 +241,31 @@ private:
|
||||
underlying m_Value;
|
||||
};
|
||||
|
||||
template <typename Derived, typename underlying>
|
||||
requires (!integral<underlying>)
|
||||
class Enum<Derived, false, underlying> {
|
||||
public:
|
||||
constexpr Enum(underlying value) : m_Value(value) {
|
||||
static_assert(
|
||||
requires { Derived::All; },
|
||||
"Derived enum must define all possible enum values.");
|
||||
|
||||
assert(std::ranges::any_of(Derived::All, [&](auto v) { return v == value; }) &&
|
||||
"Invalid enum value.");
|
||||
}
|
||||
|
||||
constexpr Enum(const Enum&) = default;
|
||||
|
||||
constexpr friend bool operator== (Enum lhs, Enum rhs) = default;
|
||||
|
||||
constexpr underlying value() const {
|
||||
return m_Value;
|
||||
}
|
||||
|
||||
private:
|
||||
underlying m_Value;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
concept special_enum = requires {
|
||||
T::is_special_enum_v;
|
||||
|
||||
Reference in New Issue
Block a user