67concept flag_enum = std::is_enum_v<E> && enable_flags_operators<E>;
108 constexpr flags() noexcept = default;
119 : value_(std::to_underlying(e)) {}
138 value_ |= other.value_;
159 value_ &= other.value_;
180 value_ ^= other.value_;
203 value_ &= ~other.value_;
228 return other.value_ != 0 && (value_ & other.value_) == other.value_;
240 [[nodiscard]]
constexpr bool contains_any(
flags other)
const noexcept {
return (value_ & other.value_) != 0; }
247 [[nodiscard]]
constexpr bool empty() const noexcept {
return value_ == 0; }
254 [[nodiscard]]
constexpr explicit operator bool() const noexcept {
return value_ != 0; }
289 [[nodiscard]]
constexpr bool operator==(E e)
const noexcept {
return value_ == std::to_underlying(e); }
367 char buf[2 +
sizeof(underlying) * 2];
370 auto [ptr, ec] = std::to_chars(buf + 2, buf +
sizeof(buf), f.
value(), 16);
371 return std::string(buf, ptr);
376#include "sdkconfig.h"
377#ifdef CONFIG_IDFXX_STD_FORMAT
382template<
idfxx::flag_enum E>
384 constexpr auto parse(format_parse_context& ctx) {
return ctx.begin(); }
386 template<
typename FormatContext>
389 return std::copy(s.begin(), s.end(), ctx.out());
Type-safe set of flags from a scoped enum.
constexpr flags operator|(flags other) const noexcept
Combines flags using bitwise OR.
constexpr bool operator==(flags const &) const noexcept=default
Equality comparison between flags objects.
constexpr underlying value() const noexcept
Returns the underlying integral value.
std::underlying_type_t< E > underlying
The underlying integral type of the enum.
constexpr bool contains_any(flags other) const noexcept
Checks if any of the specified flags are set.
constexpr flags operator-(flags other) const noexcept
Clears specific flags (set difference).
constexpr bool contains(flags other) const noexcept
Checks if all specified flags are set.
constexpr flags() noexcept=default
Default constructor, initializes to empty flags (zero).
static constexpr flags from_raw(underlying v) noexcept
Constructs flags from a raw underlying value.
constexpr bool empty() const noexcept
Checks if no flags are set.
constexpr flags operator&(flags other) const noexcept
Intersects flags using bitwise AND.
constexpr bool operator==(E e) const noexcept
Equality comparison with an individual enum value.
constexpr flags operator^(flags other) const noexcept
Toggles flags using bitwise XOR.
constexpr flags & operator|=(flags other) noexcept
Combines flags in-place using bitwise OR.
constexpr flags & operator&=(flags other) noexcept
Intersects flags in-place using bitwise AND.
E enum_type
The scoped enum type.
constexpr flags operator~() const noexcept
Computes the bitwise complement.
constexpr flags & operator^=(flags other) noexcept
Toggles flags in-place using bitwise XOR.
constexpr flags & operator-=(flags other) noexcept
Clears specific flags in-place (set difference).
Concept for enums that have opted into flag operators.
std::string to_string(core_id c)
Returns a string representation of a CPU core identifier.
constexpr flags< E > operator~(E a) noexcept
Computes the bitwise complement of an enum value.
constexpr bool enable_flags_operators
Opt-in trait for enabling flag operators on an enum.
constexpr flags< E > operator^(E a, E b) noexcept
Toggles two enum values into a flags object.
flags(E) -> flags< E >
Class template argument deduction guide.
constexpr flags< E > operator|(E a, E b) noexcept
Combines two enum values into a flags object.
constexpr flags< E > operator&(E a, E b) noexcept
Intersects two enum values into a flags object.