idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches

Type-safe bitfield operations on scoped enums. More...

Namespaces

namespace  idfxx
 

Detailed Description

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)) { ... }