![]() |
dfx 0.1.0
Linux-based dynamic dataflow executor
|
Typesafe enum bitmask wrapper and helper macros. More...
Go to the source code of this file.
Classes | |
| class | dfx::Utils::Flags< Enum > |
| Typesafe bitmask wrapper for enum flags. More... | |
Concepts | |
| concept | dfx::Utils::IsEnum |
| Concept matching any enumeration type. This is used to constrain Flags to be instantiated only with enum types. | |
Macros | |
| #define | DECLARE_FLAGS(FlagsName, Enum) |
| Declare a convenient alias for dfx::Utils::Flags<Enum>. | |
| #define | DECLARE_OPERATOR_FOR_FLAGS(FlagsName) |
| Declare a free operator| to combine two enum values into a Flags. | |
| #define | DECLARE_STD_FORMATTER_FOR_FLAGS(FlagsName) |
| Declare a std::formatter<FlagsName> that prints set flags joined by |. | |
Typesafe enum bitmask wrapper and helper macros.
This header provides dfx::Utils::Flags<Enum>, a small utility class wrapping an enum used as a bitmask (flag enum), plus a few convenience macros to create aliases and boilerplate operators / formatters.
1) Define the enum and register its string mapping (see EnumString.hpp):
2) Declare the flag type and helpers:
3) Use it:
| #define DECLARE_FLAGS | ( | FlagsName, | |
| Enum ) |
Declare a convenient alias for dfx::Utils::Flags<Enum>.
| FlagsName | Alias name to create. |
| Enum | Enum type used as the flag bitmask. |
| #define DECLARE_OPERATOR_FOR_FLAGS | ( | FlagsName | ) |
Declare a free operator| to combine two enum values into a Flags.
This enables expressions like:
| FlagsName | The Flags alias/type (e.g. Modes) for which to generate the operator. |
| #define DECLARE_STD_FORMATTER_FOR_FLAGS | ( | FlagsName | ) |
Declare a std::formatter<FlagsName> that prints set flags joined by |.
The formatter enumerates all possible flags using dfx::Enum::allValues<Enum>() (provided by EnumString.hpp macros), retains those present in the flag set, then formats them as: flag1|flag2|flag3.
| FlagsName | The Flags alias/type for which to generate a formatter. |