diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-07 22:00:01 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-07 22:00:01 +0200 |
commit | 766909047b6873b5af3f9aa98c6ed8cd53c6cc54 (patch) | |
tree | 3b32bc3035f14c2072fd687e2c9b18b7860c88e0 /compat | |
parent | d19a44bcb53cebbee0ae51981f66b93b31cb9dcb (diff) |
a
Diffstat (limited to 'compat')
-rw-r--r-- | compat/enum-bitset.hpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/compat/enum-bitset.hpp b/compat/enum-bitset.hpp new file mode 100644 index 00000000..bf705138 --- /dev/null +++ b/compat/enum-bitset.hpp @@ -0,0 +1,17 @@ +#pragma once +#include <bitset> + +namespace Magnum::Examples { + +template<typename Enum> +struct enum_bitset : std::bitset<(std::size_t)Enum::MAX> { + 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); + } +}; + +} // namespace Magnum::Examples |