![]() |
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 347 of file EnumFlags.h.
|
explicitconstexprdefault |
|
inlineexplicitconstexpr |
Definition at line 369 of file EnumFlags.h.
|
constexprdefault |
|
constexprdefault |
|
inlineexplicitconstexpr |
Definition at line 375 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 377 of file EnumFlags.h.
|
constexprdefault |
|
inlineconstexprnoexcept |
Definition at line 599 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 462 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 652 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 628 of file EnumFlags.h.
|
inline |
Definition at line 618 of file EnumFlags.h.
|
inlinestaticconstexprnoexcept |
Definition at line 394 of file EnumFlags.h.
|
inlinestaticconstexprnoexcept |
Definition at line 388 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 646 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 606 of file EnumFlags.h.
|
inlineexplicitconstexprnoexcept |
Definition at line 508 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 528 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 560 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 551 of file EnumFlags.h.
|
constexprdefault |
|
constexprdefault |
|
inlineconstexprnoexcept |
Definition at line 522 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 516 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 585 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 591 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 572 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 578 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 542 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 566 of file EnumFlags.h.
|
inline |
Definition at line 476 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 424 of file EnumFlags.h.
|
inlineconstexpr |
Definition at line 432 of file EnumFlags.h.
|
inline |
Definition at line 612 of file EnumFlags.h.
|
inline |
Definition at line 402 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 448 of file EnumFlags.h.
|
inline |
Definition at line 468 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 440 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 456 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 640 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 418 of file EnumFlags.h.
|
staticconstexpr |
Definition at line 385 of file EnumFlags.h.
|
staticconstexpr |
Definition at line 384 of file EnumFlags.h.