Core/Flags: Add operator&|^ for enum and flags

This commit is contained in:
Jérôme Leclercq
2018-05-16 15:54:55 +02:00
parent f864fc8a52
commit 74773e9daa
3 changed files with 66 additions and 16 deletions

View File

@@ -73,12 +73,16 @@ namespace Nz
BitField m_value;
};
template<typename E> constexpr Flags<E> operator&(E lhs, Flags<E> rhs);
template<typename E> constexpr Flags<E> operator|(E lhs, Flags<E> rhs);
template<typename E> constexpr Flags<E> operator^(E lhs, Flags<E> rhs);
// Little hack to have them in both Nz and global scope
namespace FlagsOperators
{
template<typename E> constexpr std::enable_if_t<IsEnumFlag<E>::value, Flags<E>> operator~(E lhs);
template<typename E> constexpr std::enable_if_t<IsEnumFlag<E>::value, Flags<E>> operator|(E lhs, E rhs);
template<typename E> constexpr std::enable_if_t<IsEnumFlag<E>::value, Flags<E>> operator&(E lhs, E rhs);
template<typename E> constexpr std::enable_if_t<IsEnumFlag<E>::value, Flags<E>> operator|(E lhs, E rhs);
template<typename E> constexpr std::enable_if_t<IsEnumFlag<E>::value, Flags<E>> operator^(E lhs, E rhs);
}