12 #ifndef __UT_ENUMHELPER_H__
13 #define __UT_ENUMHELPER_H__
15 #include <type_traits>
17 #define UT_STATIC_CHECK_ENUM(name) \
18 static_assert(std::is_enum<name>::value, "Enum type must be used.");
23 static constexpr
bool enable =
false;
27 typename std::enable_if<UT_EnableBitMask<T>::enable,
T>
::type
32 return static_cast<T>(
static_cast<U
>(lhs) | static_cast<U>(rhs));
36 typename std::enable_if<UT_EnableBitMask<T>::enable,
T&>
::type
41 lhs =
static_cast<T>(
static_cast<U
>(lhs) | static_cast<U>(rhs));
52 return static_cast<T>(
static_cast<U
>(lhs) & static_cast<U>(rhs));
56 typename std::enable_if<UT_EnableBitMask<T>::enable,
T&>
::type
61 lhs =
static_cast<T>(
static_cast<U
>(lhs) & static_cast<U>(rhs));
66 typename std::enable_if<UT_EnableBitMask<T>::enable,
T>
::type
71 return static_cast<T>(
static_cast<U
>(lhs) ^ static_cast<U>(rhs));
75 typename std::enable_if<UT_EnableBitMask<T>::enable,
T&>
::type
80 lhs =
static_cast<T>(
static_cast<U
>(lhs) ^ static_cast<U>(rhs));
85 typename std::enable_if<UT_EnableBitMask<T>::enable,
T>
::type
90 return static_cast<T>(~static_cast<U>(lhs));
94 #define UT_ENABLE_ENUM_BIT_FLAGS(name) \
96 struct UT_EnableBitMask<name> \
98 static constexpr bool enable = true; \
101 #endif // __UT_ENUMHELPER_H__
static constexpr bool enable
std::enable_if< UT_EnableBitMask< T >::enable, T & >::type operator&=(T &lhs, T rhs)
std::enable_if< UT_EnableBitMask< T >::enable, T >::type operator&(T lhs, T rhs)
std::enable_if< UT_EnableBitMask< T >::enable, T >::type operator^(T lhs, T rhs)
std::enable_if< UT_EnableBitMask< T >::enable, T & >::type operator^=(T &lhs, T rhs)
std::enable_if< UT_EnableBitMask< T >::enable, T >::type operator~(T lhs)
#define UT_STATIC_CHECK_ENUM(name)
std::enable_if< UT_EnableBitMask< T >::enable, T >::type operator|(T lhs, T rhs)
std::enable_if< UT_EnableBitMask< T >::enable, T & >::type operator|=(T &lhs, T rhs)