#include #define ENABLE_ENUM_FLAGS(enum_type)\ template<> struct enum_traits :\ enum_traits<>::allow_bitops {};\ template struct enum_traits {}; template<> struct enum_traits { struct _allow_bitops { static constexpr bool allow_bitops = true; }; using allow_bitops = _allow_bitops; template using t = typename std::enable_if::value and enum_traits::allow_bitops, R>::type; template using u = typename std::underlying_type::type; }; template constexpr enum_traits<>::t operator~(T a) { return static_cast(~static_cast::u>(a)); } template constexpr enum_traits<>::t operator|(T a, T b) { return static_cast( static_cast::u>(a) | static_cast::u>(b)); } template constexpr enum_traits<>::t operator&(T a, T b) { return static_cast( static_cast::u>(a) & static_cast::u>(b)); } template constexpr enum_traits<>::t operator^(T a, T b) { return static_cast( static_cast::u>(a) ^ static_cast::u>(b)); } template constexpr enum_traits<>::t operator|=(T& a, T b) { a = a | b; return a; } template constexpr enum_traits<>::t operator&=(T& a, T b) { a = a & b; return a; } template constexpr enum_traits<>::t operator^=(T& a, T b) { a = a ^ b; return a; }