summaryrefslogtreecommitdiffhomepage
path: root/compat/enum-bitset.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'compat/enum-bitset.hpp')
-rw-r--r--compat/enum-bitset.hpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/compat/enum-bitset.hpp b/compat/enum-bitset.hpp
index 1365b3fb..0a1f91e4 100644
--- a/compat/enum-bitset.hpp
+++ b/compat/enum-bitset.hpp
@@ -4,16 +4,16 @@
namespace floormat {
template<typename Enum>
-requires std::is_enum_v<Enum>
-struct enum_bitset : std::bitset<(std::size_t)Enum::MAX> {
- using type = Enum;
- static_assert(std::is_same_v<std::size_t, std::common_type_t<std::size_t, std::underlying_type_t<Enum>>>);
- static_assert(std::is_same_v<Enum, std::decay_t<Enum>>);
- using std::bitset<(std::size_t)Enum::MAX>::bitset;
- constexpr bool operator[](Enum x) const { return operator[]((std::size_t)x); }
- constexpr decltype(auto) operator[](Enum x) {
- return std::bitset<(std::size_t)Enum::MAX>::operator[]((std::size_t)x);
- }
+requires (std::is_enum_v<Enum> && std::is_same_v<std::size_t, std::common_type_t<std::size_t, std::underlying_type_t<Enum>>>)
+struct enum_bitset : std::bitset<std::size_t(Enum::COUNT)> {
+ using enum_type = Enum;
+ using value_type = std::underlying_type_t<enum_type>;
+
+ static constexpr auto COUNT = std::size_t{value_type(Enum::COUNT)};
+
+ using std::bitset<COUNT>::bitset;
+ constexpr bool operator[](Enum x) const { return std::bitset<COUNT>::operator[](std::size_t{value_type(x)}); }
+ constexpr decltype(auto) operator[](Enum x) { return std::bitset<COUNT>::operator[](std::size_t{value_type(x)}); }
};
} // namespace floormat