mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-20 19:44:57 +00:00
Enhance Common::Flags
This commit is contained in:
parent
08d973bccb
commit
b53f6b00a4
1 changed files with 12 additions and 0 deletions
|
@ -218,6 +218,12 @@ class Flags
|
|||
{
|
||||
public:
|
||||
constexpr Flags() = default;
|
||||
constexpr ~Flags() = default;
|
||||
constexpr Flags(const Flags<T>& other) = default;
|
||||
constexpr Flags(Flags<T>&& other) noexcept = default;
|
||||
constexpr Flags<T>& operator=(const Flags<T>& other) = default;
|
||||
constexpr Flags<T>& operator=(Flags<T>&& other) noexcept = default;
|
||||
|
||||
constexpr Flags(std::initializer_list<T> bits)
|
||||
{
|
||||
for (auto bit : bits)
|
||||
|
@ -225,7 +231,13 @@ public:
|
|||
m_hex |= static_cast<std::underlying_type_t<T>>(bit);
|
||||
}
|
||||
}
|
||||
constexpr Flags(std::underlying_type_t<T> hex) : m_hex(hex) {}
|
||||
|
||||
FlagBit<T> operator[](T bit) { return FlagBit(m_hex, bit); }
|
||||
bool operator[](T bit) const
|
||||
{
|
||||
return (m_hex & static_cast<std::underlying_type_t<T>>(bit)) != 0;
|
||||
}
|
||||
|
||||
std::underlying_type_t<T> m_hex = 0;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue