5#define _SW_ENUM_ENABLE_BIT_OPERATIONS(T) \
7 struct _EnumSupportBitOperations<T> : std::true_type { \
26 using TUnderlying =
typename std::underlying_type<T>::type;
27 return static_cast<T
>(
static_cast<TUnderlying
>(a) |
static_cast<TUnderlying
>(b));
34 inline constexpr typename std::enable_if<std::is_enum<T>::value && _EnumSupportBitOperations<T>::value, T &>::type
44 inline constexpr typename std::enable_if<std::is_enum<T>::value && _EnumSupportBitOperations<T>::value, T>::type
47 using TUnderlying =
typename std::underlying_type<T>::type;
48 return static_cast<T
>(
static_cast<TUnderlying
>(a) &
static_cast<TUnderlying
>(b));
55 inline constexpr typename std::enable_if<std::is_enum<T>::value && _EnumSupportBitOperations<T>::value, T &>::type
65 inline constexpr typename std::enable_if<std::is_enum<T>::value && _EnumSupportBitOperations<T>::value, T>::type
68 using TUnderlying =
typename std::underlying_type<T>::type;
69 return static_cast<T
>(
static_cast<TUnderlying
>(a) ^
static_cast<TUnderlying
>(b));
76 inline constexpr typename std::enable_if<std::is_enum<T>::value && _EnumSupportBitOperations<T>::value, T &>::type
86 inline constexpr typename std::enable_if<std::is_enum<T>::value && _EnumSupportBitOperations<T>::value, T>::type
89 using TUnderlying =
typename std::underlying_type<T>::type;
90 return static_cast<T
>(~static_cast<TUnderlying>(a));
用于标记枚举是否支持位运算
Definition EnumBit.h:16