12namespace circus::utils {
24 requires(traits::Flaggable<T>)
27 "T must be an enum with u32 or u64 underlying type");
82 [[nodiscard]]
constexpr bool has(U e)
const noexcept {
84 static_assert((std::is_same_v<U, enum_type>),
85 "Types must match 'this' enum type");
96 template <
typename... Args>
97 [[nodiscard]]
constexpr bool has_any(Args &&...args)
const noexcept {
98 return (
has(std::forward<Args>(args)) || ...);
107 template <
typename... Args>
108 [[nodiscard]]
constexpr bool has_all(Args &&...args)
const noexcept {
109 return (
has(std::forward<Args>(args)) && ...);
114 return this->flags == other.flags;
119 return this->flags != other.flags;
144 using U = std::underlying_type_t<E>;
145 return static_cast<E
>(
static_cast<U
>(lhs) |
static_cast<U
>(rhs));
158 using U = std::underlying_type_t<E>;
159 return static_cast<E
>(
static_cast<U
>(lhs) &
static_cast<U
>(rhs));
171 using U = std::underlying_type_t<E>;
172 return static_cast<E
>(~static_cast<U>(val));
Provides compile-time traits and C++20 concepts for type introspection used throughout the Circus lib...
~enum_flag()=default
Destructor.
constexpr bool has_any(Args &&...args) const noexcept
Checks if this enum_flag contains any of the specified flags.
Definition enum_flag.hpp:97
constexpr bool operator!=(const enum_flag< T > &other) const noexcept
Inequality operator.
Definition enum_flag.hpp:118
enum_flag()=default
Default constructor initializes with no flags set.
constexpr enum_flag & operator|=(T fs)
Bitwise OR assignment operator to add flags.
Definition enum_flag.hpp:60
constexpr bool has(U e) const noexcept
Checks if this enum_flag contains all bits of a given flag.
Definition enum_flag.hpp:82
enum_flag & operator=(T flags)
Assignment operator from enum type.
Definition enum_flag.hpp:50
enum_flag(T initial)
Constructs enum_flag with an initial flag value.
Definition enum_flag.hpp:43
underlying_type flags
Definition enum_flag.hpp:34
constexpr bool operator()() const noexcept
Boolean conversion operator indicating if any flag is set.
Definition enum_flag.hpp:126
constexpr bool has_all(Args &&...args) const noexcept
Checks if this enum_flag contains all of the specified flags.
Definition enum_flag.hpp:108
constexpr enum_flag & operator&=(T fs)
Bitwise AND assignment operator to mask flags.
Definition enum_flag.hpp:70
typename std::underlying_type< CIRCUS_ERROR_TYPES >::type underlying_type
Definition enum_flag.hpp:31
constexpr bool operator==(const enum_flag< T > &other) const noexcept
Equality operator.
Definition enum_flag.hpp:113
CIRCUS_ERROR_TYPES enum_type
Definition enum_flag.hpp:30
Concept for enum types that are eligible for flagging (i.e., bitmask ops).
Definition circus_traits.hpp:127
constexpr E operator&(E lhs, E rhs)
Bitwise AND operator for enum types flagged by circus::traits::Flaggable.
Definition enum_flag.hpp:157
constexpr E operator|(E lhs, E rhs)
Bitwise OR operator for enum types flagged by circus::traits::Flaggable.
Definition enum_flag.hpp:143
constexpr E operator~(E val)
Bitwise NOT operator for enum types flagged by circus::traits::Flaggable.
Definition enum_flag.hpp:170