33 template <
typename EnumType,
typename Underlying =
int>
93 return Flags (f1) |= f2;
103 return Flags (f1) ^= f2;
113 return Flags (f1) &= f2;
121 Flags result (*
this);
122 result.
m_flags = ~result.m_flags;
167 setFlags (
static_cast<Underlying
> (singleFlag));
183 clearFlags (
static_cast<Underlying
> (singleFlag));
A type-safe flags class for bitwise operations on enum values.
bool operator!=(const Flags &other)
Inequality comparison operator.
bool operator==(const Flags &other)
Equality comparison operator.
Flags(const Flags &original)
Copy constructor that creates a new Flags object from an existing one.
Flags & operator|=(const Flags &f)
Bitwise OR assignment operator. Combines this flags object with another using bitwise OR operation.
Flags(Underlying original=0)
Default constructor that initializes flags with a given value.
friend Flags operator|(const Flags &f1, const Flags &f2)
Bitwise OR operator for combining two Flags objects.
Flags & operator^=(const Flags &f)
Bitwise XOR assignment operator. Combines this flags object with another using bitwise XOR operation.
Flags operator~() const
Bitwise NOT operator that inverts all bits in the flags.
Underlying m_flags
The underlying storage for the flag bits.
Flags & operator&=(const Flags &f)
Bitwise AND assignment operator. Combines this flags object with another using bitwise AND operation.
void setFlag(EnumType singleFlag)
Sets a single flag using bitwise OR operation.
void clearFlags(Underlying flags)
Clears multiple flags using bitwise AND with complement.
void setFlags(Underlying flags)
Sets multiple flags using bitwise OR operation.
void clearFlag(EnumType singleFlag)
Clears a single flag using bitwise AND with complement.
Underlying Flags::* RestrictedBool
Restricted bool type for safe boolean conversion.
friend Flags operator^(const Flags &f1, const Flags &f2)
Bitwise XOR operator for combining two Flags objects.
friend Flags operator&(const Flags &f1, const Flags &f2)
Bitwise AND operator for combining two Flags objects.
Underlying value() const
Gets the raw underlying value of the flags.
Global namespace for Piduino.