1#ifndef LIBSBX_UTILITY_FLAGS_HPP_
2#define LIBSBX_UTILITY_FLAGS_HPP_
7namespace sbx::utility {
10requires (std::is_enum_v<Enum>)
13template<
typename Enum>
16template<
typename Enum>
17concept bitmask_enum = std::is_enum_v<Enum> && enable_bitmask_operators_v<Enum>;
19template<bitmask_enum Enum>
20constexpr auto operator|(Enum lhs, Enum rhs)
noexcept -> Enum {
21 using underlying_type = std::underlying_type_t<Enum>;
22 return static_cast<Enum
>(
static_cast<underlying_type
>(lhs) |
static_cast<underlying_type
>(rhs));
25template<bitmask_enum Enum>
26constexpr auto operator|=(Enum& lhs, Enum rhs)
noexcept ->
void {
30template<bitmask_enum Enum>
31constexpr auto operator&(Enum lhs, Enum rhs)
noexcept -> Enum {
32 using underlying_type = std::underlying_type_t<Enum>;
33 return static_cast<Enum
>(
static_cast<underlying_type
>(lhs) &
static_cast<underlying_type
>(rhs));
36template<bitmask_enum Enum>
37constexpr auto operator&=(Enum& lhs, Enum rhs)
noexcept ->
void {
Definition: bitmask.hpp:11