17 #if defined(__cplusplus) && (__cplusplus >= 201402L)
18 #include <type_traits>
20 #define WUT_ENUM_BITMASK_TYPE(_type) \
21 extern "C++" { namespace { \
22 constexpr inline _type operator~(_type lhs) { \
23 return static_cast<_type>(~static_cast<std::underlying_type_t<_type>>(lhs)); \
25 constexpr inline _type operator&(_type lhs, _type rhs) { \
26 return static_cast<_type>(static_cast<std::underlying_type_t<_type>>(lhs) & static_cast<std::underlying_type_t<_type>>(rhs)); \
28 constexpr inline _type operator|(_type lhs, _type rhs) { \
29 return static_cast<_type>(static_cast<std::underlying_type_t<_type>>(lhs) | static_cast<std::underlying_type_t<_type>>(rhs)); \
31 constexpr inline _type operator^(_type lhs, _type rhs) { \
32 return static_cast<_type>(static_cast<std::underlying_type_t<_type>>(lhs) ^ static_cast<std::underlying_type_t<_type>>(rhs)); \
34 inline _type& operator&=(_type &lhs, _type rhs) { \
35 return reinterpret_cast<_type&>(reinterpret_cast<std::underlying_type_t<_type>&>(lhs) &= static_cast<std::underlying_type_t<_type>>(rhs)); \
37 inline _type& operator|=(_type &lhs, _type rhs) { \
38 return reinterpret_cast<_type&>(reinterpret_cast<std::underlying_type_t<_type>&>(lhs) |= static_cast<std::underlying_type_t<_type>>(rhs)); \
40 inline _type& operator^=(_type &lhs, _type rhs) { \
41 return reinterpret_cast<_type&>(reinterpret_cast<std::underlying_type_t<_type>&>(lhs) ^= static_cast<std::underlying_type_t<_type>>(rhs)); \
45 #define WUT_ENUM_BITMASK_TYPE(_type)