From b53f6b00a43d8f734fda28a7cc050e977fd8edf0 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Tue, 9 Aug 2022 12:35:25 -0700 Subject: [PATCH] Enhance Common::Flags --- Source/Core/Common/BitUtils.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Source/Core/Common/BitUtils.h b/Source/Core/Common/BitUtils.h index 8b1b196c24..134ba1fb07 100644 --- a/Source/Core/Common/BitUtils.h +++ b/Source/Core/Common/BitUtils.h @@ -218,6 +218,12 @@ class Flags { public: constexpr Flags() = default; + constexpr ~Flags() = default; + constexpr Flags(const Flags& other) = default; + constexpr Flags(Flags&& other) noexcept = default; + constexpr Flags& operator=(const Flags& other) = default; + constexpr Flags& operator=(Flags&& other) noexcept = default; + constexpr Flags(std::initializer_list bits) { for (auto bit : bits) @@ -225,7 +231,13 @@ public: m_hex |= static_cast>(bit); } } + constexpr Flags(std::underlying_type_t hex) : m_hex(hex) {} + FlagBit operator[](T bit) { return FlagBit(m_hex, bit); } + bool operator[](T bit) const + { + return (m_hex & static_cast>(bit)) != 0; + } std::underlying_type_t m_hex = 0; };