diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-31 15:30:23 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-31 15:30:23 +0100 |
commit | 089f188a5b68c87f2be32b465624841fd3c2b44f (patch) | |
tree | e9ae36eba2c5d462e95e38c682aa24dcf01fc4d3 /compat | |
parent | 870d87b3b93d34207301c0b3fb084b275599dcb5 (diff) |
shortcuts work
Diffstat (limited to 'compat')
-rw-r--r-- | compat/enum-bitset.hpp | 20 |
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 |