28 requires std::is_enum_v<T>
32 using U = std::underlying_type_t<T>;
34 using W = std::common_type_t<U, unsigned int>;
42 constexpr kFlags() noexcept = default;
47 template<std::same_as<T>... Args>
48 constexpr explicit
kFlags(const T flag, const Args... flags) noexcept :
49 mValue(static_cast<
U>((static_cast<
W>(flag) | ... | static_cast<
W>(flags)))) {}
64 constexpr auto value() const noexcept ->
U {
72 constexpr auto isSet(
const T flag)
const noexcept ->
bool {
73 const auto bits {
static_cast<W>(flag)};
74 return (0
U != bits) && (bits == (
static_cast<W>(
mValue) & bits));
81 constexpr auto set(
const T flag)
const noexcept ->
kFlags {
92 template<
class T, std::same_as<T>... Args>
constexpr auto set(const T flag) const noexcept -> kFlags
Set flag (read-modify-write of hardware registers).
std::underlying_type_t< T > U
Underlying type of flags.
constexpr auto isSet(const T flag) const noexcept -> bool
Check if flag is set (all bits of non-empty flag).
constexpr kFlags() noexcept=default
No flags set.
constexpr auto value() const noexcept -> U
Get value.
std::common_type_t< U, unsigned int > W
Type of bit operations (at least unsigned int: narrower types would be promoted to int).
static constexpr auto from(const U value) noexcept -> kFlags
From raw value (hardware register, table entry).
Freestanding kernel library: printing, math, alignment, flags, strings.
constexpr auto make_kflags(const Args... flags) noexcept -> kFlags< T >
Flags creation helper function from set flags.