#pragma once #include template struct is_enum_bitfield { static constexpr bool value = false; }; #define IS_BITFIELD(name) \ template<> struct is_enum_bitfield {static constexpr bool value=true;} template typename std::enable_if::value,E>::type operator & (E lhs, E rhs) { return static_cast ( static_cast::type>(lhs) & static_cast::type>(rhs)); } template typename std::enable_if::value,E>::type operator ^ (E lhs, E rhs) { return static_cast ( static_cast::type>(lhs) ^ static_cast::type>(rhs)); } template typename std::enable_if::value,E>::type operator ~ (E rhs) { return static_cast(~static_cast::type>(rhs)); } template typename std::enable_if::value,E>::type& operator |= (E &lhs, E rhs) { lhs = static_cast( static_cast::type>(lhs) | static_cast::type>(rhs)); return lhs; } template typename std::enable_if::value,E>::type& operator &= (E &lhs, E rhs) { lhs = static_cast( static_cast::type>(lhs) & static_cast::type>(rhs)); return lhs; } template typename std::enable_if::value,E>::type& operator ^= (E &lhs, E rhs) { lhs = static_cast( static_cast::type>(lhs) ^ static_cast::type>(rhs)); return lhs; } template typename std::enable_if::value,bool>::type operator ! (E rhs) { return static_cast::type>(rhs) == 0; }