#pragma once #include namespace cocos2d{ template struct EnableBitMaskOperators { static const bool enable = false; }; template typename std::enable_if::enable, Enum>::type operator |(Enum lhs, Enum rhs) { using underlying = typename std::underlying_type::type; return static_cast ( static_cast(lhs) | static_cast(rhs) ); } template typename std::enable_if::enable, bool>::type operator ==(Enum lhs, Enum rhs) { using underlying = typename std::underlying_type::type; static_cast(lhs) == static_cast(rhs); } template typename std::enable_if::enable, Enum>::type& operator |=(Enum& lhs, Enum rhs) { using underlying = typename std::underlying_type::type; lhs = static_cast ( static_cast(lhs) | static_cast(rhs) ); return lhs; } template typename std::enable_if::enable, unsigned int>::type operator &(Enum lhs, Enum rhs) { using underlying = typename std::underlying_type::type; using impl_type = typename std::make_unsigned::type; return impl_type ( static_cast(lhs) & static_cast(rhs) ); } #define ENABLE_BITMASK_OPERATORS(x) \ template<> \ struct EnableBitMaskOperators \ { \ static const bool enable = true; \ }; } // end of namespace cocos2d{