![]() |
Project
|
Classs to aggregate and manage enum-based on-off flags. More...
#include <EnumFlags.h>
Public Member Functions | |
constexpr | EnumFlags ()=default |
constexpr | EnumFlags (E e) |
constexpr | EnumFlags (const EnumFlags &)=default |
constexpr | EnumFlags (EnumFlags &&)=default |
constexpr | EnumFlags (U u) |
constexpr | EnumFlags (std::initializer_list< E > flags) noexcept |
constexpr | ~EnumFlags ()=default |
void | set (const std::string &s, int base=2) |
constexpr auto | value () const noexcept |
constexpr void | reset () noexcept |
template<typename T > requires std::is_same_v<T, E> | |
constexpr void | reset (T t) |
template<typename T > requires std::is_same_v<T, E> | |
constexpr bool | test (T t) const noexcept |
template<typename T > requires std::is_same_v<T, E> | |
constexpr void | set (T t) noexcept |
template<typename T > requires std::is_same_v<T, E> | |
constexpr void | toggle (T t) noexcept |
constexpr bool | any () const noexcept |
std::string | string () const |
std::string | pstring (bool withNewline=false) const |
constexpr | operator bool () const noexcept |
template<typename T > requires std::is_same_v<T, E> | |
constexpr bool | operator[] (const T t) noexcept |
constexpr bool | operator== (const EnumFlags &o) const noexcept |
constexpr bool | operator!= (const EnumFlags &o) const noexcept |
constexpr EnumFlags & | operator= (const EnumFlags &o)=default |
constexpr EnumFlags & | operator= (EnumFlags &&o)=default |
template<typename T > requires std::is_same_v<T, E> | |
constexpr EnumFlags & | operator|= (T t) noexcept |
template<typename T > requires std::is_same_v<T, E> | |
constexpr EnumFlags & | operator&= (T t) noexcept |
template<typename T > requires std::is_same_v<T, E> | |
constexpr EnumFlags | operator& (T t) const noexcept |
constexpr EnumFlags | operator~ () const noexcept |
constexpr EnumFlags | operator| (const EnumFlags &o) const noexcept |
constexpr EnumFlags & | operator|= (const EnumFlags &o) noexcept |
constexpr EnumFlags | operator^ (const EnumFlags &o) const noexcept |
constexpr EnumFlags & | operator^= (const EnumFlags &o) noexcept |
template<typename... Ts> | |
constexpr bool | all_of (Ts... flags) const noexcept |
template<typename... Ts> | |
constexpr bool | none_of (Ts... flags) const noexcept |
std::string | serialize () const |
void | deserialize (const std::string &data) |
constexpr size_t | count () const noexcept |
constexpr EnumFlags | union_with (const EnumFlags &o) const noexcept |
constexpr EnumFlags | intersection_with (const EnumFlags &o) const noexcept |
constexpr bool | contains (const EnumFlags &other) const noexcept |
Static Public Member Functions | |
static constexpr auto | getValues () noexcept |
static constexpr auto | getNames () noexcept |
Static Public Attributes | |
static constexpr U | None {0} |
static constexpr U | All {H::MaxRep} |
Classs to aggregate and manage enum-based on-off flags.
This class manages flags as bits in the underlying type of an enum, allowing manipulation via enum member names. It supports operations akin to std::bitset but is fully constexpr and is ideal for aggregating multiple on-off booleans, e.g., enabling/disabling algorithm features.
Example: enum class AlgoOptions { Feature1, Feature2, Feature3, }; ... EnumFlags<AlgoOptions> opts; opts.set("Feature1 | Feature3"); // Set Feature1 and Feature3. if (opts[AlgoOptions::Feature1]) { // Do some work. } // Check if Feature1 is set.
Additional examples of how to use this class are in testEnumFlags.cxx.
Definition at line 346 of file EnumFlags.h.
|
explicitconstexprdefault |
|
inlineexplicitconstexpr |
Definition at line 368 of file EnumFlags.h.
|
constexprdefault |
|
constexprdefault |
|
inlineexplicitconstexpr |
Definition at line 374 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 376 of file EnumFlags.h.
|
constexprdefault |
|
inlineconstexprnoexcept |
Definition at line 595 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 458 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 648 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 624 of file EnumFlags.h.
|
inline |
Definition at line 614 of file EnumFlags.h.
|
inlinestaticconstexprnoexcept |
Definition at line 393 of file EnumFlags.h.
|
inlinestaticconstexprnoexcept |
Definition at line 387 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 642 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 602 of file EnumFlags.h.
|
inlineexplicitconstexprnoexcept |
Definition at line 504 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 524 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 556 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 547 of file EnumFlags.h.
|
constexprdefault |
|
constexprdefault |
|
inlineconstexprnoexcept |
Definition at line 518 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 512 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 581 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 587 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 568 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 574 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 538 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 562 of file EnumFlags.h.
|
inline |
Definition at line 472 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 420 of file EnumFlags.h.
|
inlineconstexpr |
Definition at line 428 of file EnumFlags.h.
|
inline |
Definition at line 608 of file EnumFlags.h.
|
inline |
Definition at line 401 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 444 of file EnumFlags.h.
|
inline |
Definition at line 464 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 436 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 452 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 636 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 414 of file EnumFlags.h.
|
staticconstexpr |
Definition at line 384 of file EnumFlags.h.
|
staticconstexpr |
Definition at line 383 of file EnumFlags.h.