|
idfxx 1.0.0
Modern C++23 components for ESP-IDF
|
Type-safe set of flags from a scoped enum. More...
#include <idfxx_core/include/idfxx/flags.hpp>
Public Types | |
| using | enum_type = E |
| The scoped enum type. | |
| using | underlying = std::underlying_type_t< E > |
| The underlying integral type of the enum. | |
Public Member Functions | |
| constexpr | flags () noexcept=default |
| Default constructor, initializes to empty flags (zero). | |
| constexpr | flags (E e) noexcept |
| Constructs from a single enum value. | |
| constexpr flags | operator| (flags other) const noexcept |
| Combines flags using bitwise OR. | |
| constexpr flags & | operator|= (flags other) noexcept |
| Combines flags in-place using bitwise OR. | |
| constexpr flags | operator& (flags other) const noexcept |
| Intersects flags using bitwise AND. | |
| constexpr flags & | operator&= (flags other) noexcept |
| Intersects flags in-place using bitwise AND. | |
| constexpr flags | operator^ (flags other) const noexcept |
| Toggles flags using bitwise XOR. | |
| constexpr flags & | operator^= (flags other) noexcept |
| Toggles flags in-place using bitwise XOR. | |
| constexpr flags | operator- (flags other) const noexcept |
| Clears specific flags (set difference). | |
| constexpr flags & | operator-= (flags other) noexcept |
| Clears specific flags in-place (set difference). | |
| constexpr flags | operator~ () const noexcept |
| Computes the bitwise complement. | |
| constexpr bool | contains (flags other) const noexcept |
| Checks if all specified flags are set. | |
| constexpr bool | contains_any (flags other) const noexcept |
| Checks if any of the specified flags are set. | |
| constexpr bool | empty () const noexcept |
| Checks if no flags are set. | |
| constexpr | operator bool () const noexcept |
| Explicit conversion to bool. | |
| constexpr bool | operator== (flags const &) const noexcept=default |
| Equality comparison between flags objects. | |
| constexpr bool | operator== (E e) const noexcept |
| Equality comparison with an individual enum value. | |
Type-safe set of flags from a scoped enum.
Provides type-safe bitflag operations with full operator support. Individual enum values implicitly convert to flags<E>, allowing natural syntax like: auto f = my_flag::a | my_flag::b;
All operations are constexpr and marked [[nodiscard]] to prevent accidental misuse. The class provides zero-overhead abstractions over raw bitwise operations.
Requires opt-in via:
| E | The flag enum type (must satisfy flag_enum concept). |
| using idfxx::flags< E >::enum_type = E |
| using idfxx::flags< E >::underlying = std::underlying_type_t<E> |
|
constexprdefaultnoexcept |
Default constructor, initializes to empty flags (zero).
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineexplicitconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
constexprdefaultnoexcept |
Equality comparison between flags objects.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |