19 #include <type_traits>
43 static constexpr
bool enable =
false;
47 typename std::enable_if_t<EnableBitmaskOps<T>::enable,
T> constexpr
operator&(
T lhs,
49 using type =
typename std::underlying_type_t<T>;
50 return static_cast<T>(
static_cast<type>(lhs) & static_cast<type>(rhs));
53 typename std::enable_if_t<EnableBitmaskOps<T>::enable,
T> constexpr
operator|(
T lhs,
55 using type =
typename std::underlying_type_t<T>;
56 return static_cast<T>(
static_cast<type>(lhs) | static_cast<type>(rhs));
59 typename std::enable_if_t<EnableBitmaskOps<T>::enable,
T> constexpr
operator~(
T t) {
60 return static_cast<T>(~static_cast<std::underlying_type_t<T>>(t));
63 typename std::enable_if_t<EnableBitmaskOps<T>::enable,
T> constexpr
operator|=(
T& lhs,
69 typename std::enable_if_t<EnableBitmaskOps<T>::enable,
T> constexpr
operator&=(
T& lhs,
76 typename std::enable_if_t<EnableBitmaskOps<T>::enable,
bool> constexpr
any_bits_set(
T t) {
77 using type =
typename std::underlying_type_t<T>;
78 constexpr
type zero{};
79 return static_cast<type>(t) != zero;
82 #define ENABLE_BITMASK_OPS(x) \
84 struct EnableBitmaskOps<x> { \
85 static constexpr bool enable = true; \
std::enable_if_t< EnableBitmaskOps< T >::enable, T > constexpr operator|(T lhs, T rhs)
std::enable_if_t< EnableBitmaskOps< T >::enable, T > constexpr operator|=(T &lhs, T rhs)
std::enable_if_t< EnableBitmaskOps< T >::enable, bool > constexpr any_bits_set(T t)
std::enable_if_t< EnableBitmaskOps< T >::enable, T > constexpr operator&=(T &lhs, T rhs)
std::enable_if_t< EnableBitmaskOps< T >::enable, T > constexpr operator&(T lhs, T rhs)
std::enable_if_t< EnableBitmaskOps< T >::enable, T > constexpr operator~(T t)
static constexpr bool enable