14#include <egt/detail/meta.h>
15#include <initializer_list>
41 using Underlying =
typename std::underlying_type<T>::type;
54 constexpr FlagsBase(std::initializer_list<T> flags)
noexcept
56 for (
auto& flag : flags)
64 EGT_NODISCARD
constexpr bool is_set(
const T flag)
const noexcept
74 EGT_NODISCARD
constexpr bool is_set(std::initializer_list<T> flags)
const noexcept
76 for (
auto& flag : flags)
87 constexpr bool set(
const T flag)
noexcept
100 constexpr bool set(std::initializer_list<T> flags)
noexcept
102 bool inserted =
false;
103 for (
auto& flag : flags)
120 constexpr bool clear(
const T flag)
noexcept
122 bool changed =
false;
136 EGT_NODISCARD
constexpr bool empty() const noexcept
147 const bool diff =
m_flags != 0;
153 EGT_NODISCARD std::set<T>
get()
const
156 const auto bits = std::numeric_limits<Underlying>::digits;
157 for (
auto b = 0; b < bits; b++)
160 result.insert(
static_cast<T
>(1u << b));
Utility class for managing a set of flags.
Definition flagsbase.h:34
EGT_NODISCARD constexpr bool is_set(std::initializer_list< T > flags) const noexcept
Test if the specified flags are set.
Definition flagsbase.h:74
EGT_NODISCARD std::set< T > get() const
Get a std::set of all set flags.
Definition flagsbase.h:153
constexpr FlagsBase(std::initializer_list< T > flags) noexcept
Construct with an initializer_list of flags.
Definition flagsbase.h:54
EGT_NODISCARD constexpr bool empty() const noexcept
Returns true if there are no flags set.
Definition flagsbase.h:136
constexpr Underlying & raw()
Get the raw underlying value.
Definition flagsbase.h:173
EGT_NODISCARD constexpr const Underlying & raw() const
Get the raw underlying value.
Definition flagsbase.h:167
Underlying m_flags
The flags.
Definition flagsbase.h:188
constexpr bool set(const T flag) noexcept
Set the specified flag.
Definition flagsbase.h:87
constexpr FlagsBase() noexcept=default
typename std::underlying_type< T >::type Underlying
This is the underlying type of the flags, which is used internally for efficient bitwise operation on...
Definition flagsbase.h:41
constexpr bool clear() noexcept
Unset all flags.
Definition flagsbase.h:145
constexpr bool clear(const T flag) noexcept
Clear, or unset, the specified flag.
Definition flagsbase.h:120
EGT_NODISCARD constexpr bool is_set(const T flag) const noexcept
Test if the specified flag is set.
Definition flagsbase.h:64
constexpr bool set(std::initializer_list< T > flags) noexcept
Set the specified flags.
Definition flagsbase.h:100
EGT framework namespace.
Definition animation.h:24