Type-safe bitfield operations on scoped enums.
More...
Type-safe bitfield operations on scoped enums.
Provides the flags<E> template class for type-safe flag combinations with operator overloading. Requires opt-in via enable_flags_operators<E>.
enum class my_flags : uint32_t {
none = 0,
read = 1u << 0,
write = 1u << 1,
exec = 1u << 2,
};
template<>
inline constexpr bool idfxx::enable_flags_operators<my_flags> = true;
auto perms = my_flags::read | my_flags::write;
if (perms.contains(my_flags::write)) { ... }
◆ operator&()
Intersects two enum values into a flags object.
- Parameters
-
| a | First flag value. |
| b | Second flag value. |
- Returns
- A flags object containing the intersection.
Definition at line 352 of file flags.hpp.
◆ operator^()
Toggles two enum values into a flags object.
- Parameters
-
| a | First flag value. |
| b | Second flag value. |
- Returns
- A flags object with toggled bits.
Definition at line 365 of file flags.hpp.
◆ operator|()
Combines two enum values into a flags object.
Enables natural syntax for combining flag enum values without explicitly constructing flags objects.
- Parameters
-
| a | First flag value. |
| b | Second flag value. |
- Returns
- A flags object containing both flags.
Definition at line 339 of file flags.hpp.
◆ operator~()
Computes the bitwise complement of an enum value.
- Parameters
-
| a | The flag value to complement. |
- Returns
- A flags object with all bits inverted.
Definition at line 377 of file flags.hpp.