no need for "count"

This commit is contained in:
lizzie 2026-06-06 04:08:13 +00:00
parent 1edc77cb53
commit 62f6bb9d1c
2 changed files with 4 additions and 2 deletions

View file

@ -75,7 +75,7 @@ struct EnumMetadata {
#define PP_HEAD(A, ...) A
#define ENUM(NAME, ...) \
enum class NAME : u32 { __VA_ARGS__, Count }; \
enum class NAME : u32 { __VA_ARGS__ }; \
template<> inline std::vector<std::pair<std::string_view, NAME>> EnumMetadata<NAME>::Canonicalizations() { \
return {PAIR(NAME, __VA_ARGS__)}; \
} \

View file

@ -375,7 +375,9 @@ public:
// Enums have a maximal range which they're allowed
Type temp{};
if constexpr (std::is_enum_v<Type>) {
temp = Type(std::clamp(std::underlying_type_t<Type>(val), std::underlying_type_t<Type>(0), std::underlying_type_t<Type>(Type::Count) - 1));
auto const r_min = std::underlying_type_t<Type>(0);
auto const r_max = std::underlying_type_t<Type>(EnumMetadata<Type>::GetLast());
temp = Type(std::clamp(std::underlying_type_t<Type>(val), r_min, r_max));
} else {
temp = ranged ? std::clamp(val, this->minimum, this->maximum) : val;
}