Core/Flags: Move external operators to the global scope

Fixes usage of those operators outside of the Nz namespace, global
scoping is not an issue thanks to the enable_if
This commit is contained in:
Lynix 2017-02-15 07:13:00 +01:00
parent 1a677387d1
commit 7cc11245f9
2 changed files with 62 additions and 63 deletions

View File

@ -54,13 +54,13 @@ namespace Nz
private:
BitField m_value;
};
template<typename E> constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator~(E lhs);
template<typename E> constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator|(E lhs, E rhs);
template<typename E> constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator&(E lhs, E rhs);
template<typename E> constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator^(E lhs, E rhs);
}
template<typename E> constexpr std::enable_if_t<Nz::EnumAsFlags<E>::value, Nz::Flags<E>> operator~(E lhs);
template<typename E> constexpr std::enable_if_t<Nz::EnumAsFlags<E>::value, Nz::Flags<E>> operator|(E lhs, E rhs);
template<typename E> constexpr std::enable_if_t<Nz::EnumAsFlags<E>::value, Nz::Flags<E>> operator&(E lhs, E rhs);
template<typename E> constexpr std::enable_if_t<Nz::EnumAsFlags<E>::value, Nz::Flags<E>> operator^(E lhs, E rhs);
#include <Nazara/Core/Flags.inl>
#endif // NAZARA_FLAGS_HPP

View File

@ -209,7 +209,7 @@ namespace Nz
{
return 1U << static_cast<BitField>(enumValue);
}
}
/*!
* \brief Override binary NOT operator on enum to turns into a Flags object.
@ -220,9 +220,9 @@ namespace Nz
* Returns a Flags object with all state enabled except for the enum one.
*/
template<typename E>
constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator~(E lhs)
constexpr std::enable_if_t<Nz::EnumAsFlags<E>::value, Nz::Flags<E>> operator~(E lhs)
{
return ~Flags<E>(lhs);
return ~Nz::Flags<E>(lhs);
}
/*!
@ -235,9 +235,9 @@ namespace Nz
* Returns a Flags object with combined states from the two enumeration values.
*/
template<typename E>
constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator|(E lhs, E rhs)
constexpr std::enable_if_t<Nz::EnumAsFlags<E>::value, Nz::Flags<E>> operator|(E lhs, E rhs)
{
return Flags<E>(lhs) | rhs;
return Nz::Flags<E>(lhs) | rhs;
}
/*!
@ -251,9 +251,9 @@ namespace Nz
* In this case, only one flag will be enabled if both enumeration values are the same.
*/
template<typename E>
constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator&(E lhs, E rhs)
constexpr std::enable_if_t<Nz::EnumAsFlags<E>::value, Nz::Flags<E>> operator&(E lhs, E rhs)
{
return Flags<E>(lhs) & rhs;
return Nz::Flags<E>(lhs) & rhs;
}
/*!
@ -267,10 +267,9 @@ namespace Nz
* In this case, two flags will be enabled if both the enumeration values are different.
*/
template<typename E>
constexpr std::enable_if_t<EnumAsFlags<E>::value, Flags<E>> operator^(E lhs, E rhs)
constexpr std::enable_if_t<Nz::EnumAsFlags<E>::value, Nz::Flags<E>> operator^(E lhs, E rhs)
{
return Flags<E>(lhs) ^ rhs;
}
return Nz::Flags<E>(lhs) ^ rhs;
}
#include <Nazara/Core/DebugOff.hpp>