#pragma once #include template struct enable_bitmask : std::false_type {}; #define RENDERIVE_ENABLE_BITMASK(E) \ template <> \ struct enable_bitmask : std::true_type {}; template constexpr std::enable_if_t::value, E> operator|(E lhs, E rhs) { using U = std::underlying_type_t; return static_cast(static_cast(lhs) | static_cast(rhs)); } template constexpr std::enable_if_t::value, E> operator&(E lhs, E rhs) { using U = std::underlying_type_t; return static_cast(static_cast(lhs) & static_cast(rhs)); } template constexpr std::enable_if_t::value, E> operator^(E lhs, E rhs) { using U = std::underlying_type_t; return static_cast(static_cast(lhs) ^ static_cast(rhs)); } template constexpr std::enable_if_t::value, E> operator~(E e) { using U = std::underlying_type_t; return static_cast(~static_cast(e)); } template constexpr std::enable_if_t::value, E&> operator|=(E& lhs, E rhs) { return lhs = lhs | rhs; } template constexpr std::enable_if_t::value, E&> operator&=(E& lhs, E rhs) { return lhs = lhs & rhs; }