![]() |
Utilities
Utilities header only library
|
Template implementation of Enum Flags. Allows the setting and checking of enum values. More...
Public Member Functions | |
| EnumFlags () | |
| Constructor with no flags to be set. | |
| template<typename... Types> | |
| EnumFlags (const EnumType val1, Types ... valn) | |
| Variadic constructor with a variable amount of flags to be set. | |
| EnumFlags (const std::vector< EnumType > &values) | |
| Construct from std::vector. | |
| void | Set (const T val) |
| Set a single flag. | |
| bool | IsSet (const T val) const |
| Checks whether a given flag is set. | |
| uint8_t | CountSet () const |
| Returns the number of flags set. | |
| bool | IsAnySet () const |
| Return whether there is at least one flag set. | |
| std::vector< T > | ToVector () const |
| Creates a vector containing all elements set. | |
| bool | operator== (const T &value) const |
| Check whether the flags are exactly one single value. | |
| bool | operator!= (const T &value) const |
| Check whether the flags are not exactly one single value. | |
| EnumFlags< T, TMask > & | operator+= (const EnumFlags< T, TMask > &other) |
| Add other flags. | |
Template implementation of Enum Flags. Allows the setting and checking of enum values.
Example usage:
The underlying enum class should have its values starting with 0 and incrementing by 1, i.e. default. In case of enum classes with many values, consider using a larger storage type for the bit mask - template argument TMask.