Flags
-
template<IsEnum ENUM>
class Flags Template for creating a type that can do a bit-wise OR on values defined as enum.
Example:
enum MyFlag : unsigned int { FLAG1 = 0x1, FLAG2 = 0x2, FLAG3 = 0x4 }; using MyFlags = Flags<MyFlag>; MyFlags flags = FLAG1 | FLAG3; assert(flags & FLAG1); assert(flags & FLAG3);
- Template Parameters:
ENUM – enum defining the flags
Public Functions
-
inline constexpr bool has_flags() const noexcept
Test if there are set flags.
- Returns:
trueif there are any flags set,falseotherwise
-
inline constexpr Flags &operator|=(ENUM rhs) noexcept
Set a flag.
- Parameters:
rhs – Flag to set
- Returns:
New flags
-
inline constexpr Flags &operator|=(Flags rhs)
Set flags.
- Parameters:
rhs – Flags to set
- Returns:
New flags
-
inline constexpr Flags operator|(ENUM rhs) const noexcept
Add a new flag and return the result.
- Parameters:
rhs – Flag to add
- Returns:
New flags