mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-03 06:39:33 +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:
|
public:
|
||||||
constexpr Flags() = default;
|
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)
|
constexpr Flags(std::initializer_list<T> bits)
|
||||||
{
|
{
|
||||||
for (auto bit : bits)
|
for (auto bit : bits)
|
||||||
|
@ -225,7 +231,13 @@ public:
|
||||||
m_hex |= static_cast<std::underlying_type_t<T>>(bit);
|
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); }
|
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;
|
std::underlying_type_t<T> m_hex = 0;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue