![]() |
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 |
EnumFlags (const std::string &str) | |
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... Ts> | |
constexpr bool | test (Ts... flags) 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 |
constexpr bool | all () 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) const 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) 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 (upto 64 bits), 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 356 of file EnumFlags.h.
|
explicitconstexprdefault |
|
inlineexplicitconstexpr |
Definition at line 378 of file EnumFlags.h.
|
constexprdefault |
|
constexprdefault |
|
inlineexplicitconstexpr |
Definition at line 384 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 386 of file EnumFlags.h.
|
inline |
Definition at line 391 of file EnumFlags.h.
|
constexprdefault |
|
inlineconstexprnoexcept |
Definition at line 489 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 632 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 483 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 679 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 661 of file EnumFlags.h.
|
inline |
Definition at line 651 of file EnumFlags.h.
|
inlinestaticconstexprnoexcept |
Definition at line 408 of file EnumFlags.h.
|
inlinestaticconstexprnoexcept |
Definition at line 402 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 673 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 639 of file EnumFlags.h.
|
inlineexplicitconstexprnoexcept |
Definition at line 535 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 555 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 618 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 587 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 578 of file EnumFlags.h.
|
constexprdefault |
|
constexprdefault |
|
inlineconstexprnoexcept |
Definition at line 549 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 543 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 612 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 624 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 599 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 605 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 569 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 593 of file EnumFlags.h.
|
inline |
Definition at line 503 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 438 of file EnumFlags.h.
|
inlineconstexpr |
Definition at line 446 of file EnumFlags.h.
|
inline |
Definition at line 645 of file EnumFlags.h.
|
inline |
Definition at line 416 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 469 of file EnumFlags.h.
|
inline |
Definition at line 495 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 454 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 461 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 477 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 667 of file EnumFlags.h.
|
inlineconstexprnoexcept |
Definition at line 432 of file EnumFlags.h.
|
staticconstexpr |
Definition at line 399 of file EnumFlags.h.
|
staticconstexpr |
Definition at line 398 of file EnumFlags.h.