24 #include <type_traits> 29 #ifndef DOXYGEN_SHOULD_SKIP_THIS 66 : m_data(static_cast<
Type>(~0))
77 : m_data(static_cast<
Type>(e))
88 return Flags(~m_data);
98 return Flags(m_data | flags.m_data);
108 m_data |= flags.m_data;
119 return Flags(m_data & flags.m_data);
129 m_data &= flags.m_data;
138 constexpr
operator bool()
const {
149 return (m_data & static_cast<Type>(flag)) != 0;
158 m_data |=
static_cast<Type>(flag);
167 m_data &= ~static_cast<
Type>(flag);
173 using Type =
typename std::underlying_type<E>::type;
273 template<
typename E,
typename ...
F>
275 return Flags<E>(flag) | combineFlags(others ...);
278 #ifndef DOXYGEN_SHOULD_SKIP_THIS 285 struct EnableBitmaskOperators {
286 static constexpr
bool value =
false;
294 typename std::enable_if<EnableBitmaskOperators<E>::value,
gf::Flags<E>>::type
295 operator|(
E lhs,
E rhs) {
301 typename std::enable_if<EnableBitmaskOperators<E>::value,
gf::Flags<E>>::type
302 operator&(
E lhs,
E rhs) {
308 typename std::enable_if<EnableBitmaskOperators<E>::value,
gf::Flags<E>>::type
typename std::underlying_type< Flip >::type Type
The underlying type of the enum.
Definition: Flags.h:173
Semantic type to represent "none".
Definition: Types.h:37
Bitfield relying on an enumeration.
Definition: Flags.h:46
Flags< E > & operator &=(Flags< E > flags)
Binary AND and assignment.
Definition: Flags.h:128
constexpr Flags< E > combineFlags(E flag, F ... others)
Combine several enum values into a flag value.
Definition: Flags.h:274
void reset(E flag)
Reset a flag.
Definition: Flags.h:166
constexpr Flags(NoneType)
Constructor with no flag set.
Definition: Flags.h:56
Semantic type to represent "all".
Definition: Types.h:53
constexpr Flags operator &(Flags flags) const
Binary AND between two bitfields.
Definition: Flags.h:118
constexpr Flags(AllType)
Constructor with all flags set.
Definition: Flags.h:65
constexpr Flags< E > operator~() const
Binary NOT operator.
Definition: Flags.h:87
constexpr Flags(E e)
Constructor with an enum value.
Definition: Flags.h:76
constexpr bool test(E flag) const
Test if a specified flag is set.
Definition: Flags.h:148
Type getValue() const
Get the underlying value of the flags.
Definition: Flags.h:182
The namespace for gf classes.
Definition: Action.h:35
Flags< E > & operator|=(Flags< E > flags)
Binary OR and assignment.
Definition: Flags.h:107
constexpr Flags operator|(Flags flags) const
Binary OR between two bitfields.
Definition: Flags.h:97
constexpr Flags< E > operator|(Flags< E > lhs, E rhs)
Binary OR between a bitfield and a flag.
Definition: Flags.h:206
constexpr Flags< E > operator|(E lhs, Flags< E > rhs)
Binary OR between a flag and a bitfield.
Definition: Flags.h:220
constexpr Flags< E > combineFlags(E flag)
Combine a single enum value into a flag value.
Definition: Flags.h:261