diff --git a/include/Nazara/Core/Flags.hpp b/include/Nazara/Core/Flags.hpp index 5285ef601..293a8dfa8 100644 --- a/include/Nazara/Core/Flags.hpp +++ b/include/Nazara/Core/Flags.hpp @@ -55,16 +55,19 @@ namespace Nz BitField m_value; }; - template constexpr std::enable_if_t::value, Flags> operator~(E lhs); - template constexpr std::enable_if_t::value, Flags> operator|(E lhs, E rhs); - template constexpr std::enable_if_t::value, Flags> operator&(E lhs, E rhs); - template constexpr std::enable_if_t::value, Flags> operator^(E lhs, E rhs); + // Little hack to have them in both Nz and global scope + namespace DetailFlagOperators + { + template constexpr std::enable_if_t::value, Flags> operator~(E lhs); + template constexpr std::enable_if_t::value, Flags> operator|(E lhs, E rhs); + template constexpr std::enable_if_t::value, Flags> operator&(E lhs, E rhs); + template constexpr std::enable_if_t::value, Flags> operator^(E lhs, E rhs); + } + + using namespace DetailFlagOperators; } -template constexpr std::enable_if_t::value, Nz::Flags> operator~(E lhs); -template constexpr std::enable_if_t::value, Nz::Flags> operator|(E lhs, E rhs); -template constexpr std::enable_if_t::value, Nz::Flags> operator&(E lhs, E rhs); -template constexpr std::enable_if_t::value, Nz::Flags> operator^(E lhs, E rhs); +using namespace Nz::DetailFlagOperators; #include diff --git a/include/Nazara/Core/Flags.inl b/include/Nazara/Core/Flags.inl index 3832d3b50..11cd22109 100644 --- a/include/Nazara/Core/Flags.inl +++ b/include/Nazara/Core/Flags.inl @@ -211,127 +211,69 @@ namespace Nz } - /*! - * \brief Override binary NOT operator on enum to turns into a Flags object. - * \return A Flags object with reversed bits. - * - * \param lhs Enumeration value to reverse. - * - * Returns a Flags object with all state enabled except for the enum one. - */ - template - constexpr std::enable_if_t::value, Flags> operator~(E lhs) + namespace DetailFlagOperators { - return ~Flags(lhs); + /*! + * \brief Override binary NOT operator on enum to turns into a Flags object. + * \return A Flags object with reversed bits. + * + * \param lhs Enumeration value to reverse. + * + * Returns a Flags object with all state enabled except for the enum one. + */ + template + constexpr std::enable_if_t::value, Flags> operator~(E lhs) + { + return ~Flags(lhs); + } + + /*! + * \brief Override binary OR operator on enum to turns into a Flags object. + * \return A Flags object with combined enum states. + * + * \param lhs First enumeration value to combine. + * \param rhs Second enumeration value to combine. + * + * Returns a Flags object with combined states from the two enumeration values. + */ + template + constexpr std::enable_if_t::value, Flags> operator|(E lhs, E rhs) + { + return Flags(lhs) | rhs; + } + + /*! + * \brief Override binary AND operator on enum to turns into a Flags object. + * \return A Flags object with compare enum states. + * + * \param lhs First enumeration value to compare. + * \param rhs Second enumeration value to compare. + * + * Returns a Flags object with compared states from the two enumeration values. + * In this case, only one flag will be enabled if both enumeration values are the same. + */ + template + constexpr std::enable_if_t::value, Flags> operator&(E lhs, E rhs) + { + return Flags(lhs) & rhs; + } + + /*! + * \brief Override binary XOR operator on enum to turns into a Flags object. + * \return A Flags object with XORed enum states. + * + * \param lhs First enumeration value to compare. + * \param rhs Second enumeration value to compare. + * + * Returns a Flags object with XORed states from the two enumeration values. + * In this case, two flags will be enabled if both the enumeration values are different. + */ + template + constexpr std::enable_if_t::value, Flags> operator^(E lhs, E rhs) + { + return Flags(lhs) ^ rhs; + } } - - /*! - * \brief Override binary OR operator on enum to turns into a Flags object. - * \return A Flags object with combined enum states. - * - * \param lhs First enumeration value to combine. - * \param rhs Second enumeration value to combine. - * - * Returns a Flags object with combined states from the two enumeration values. - */ - template - constexpr std::enable_if_t::value, Flags> operator|(E lhs, E rhs) - { - return Flags(lhs) | rhs; - } - - /*! - * \brief Override binary AND operator on enum to turns into a Flags object. - * \return A Flags object with compare enum states. - * - * \param lhs First enumeration value to compare. - * \param rhs Second enumeration value to compare. - * - * Returns a Flags object with compared states from the two enumeration values. - * In this case, only one flag will be enabled if both enumeration values are the same. - */ - template - constexpr std::enable_if_t::value, Flags> operator&(E lhs, E rhs) - { - return Flags(lhs) & rhs; - } - - /*! - * \brief Override binary XOR operator on enum to turns into a Flags object. - * \return A Flags object with XORed enum states. - * - * \param lhs First enumeration value to compare. - * \param rhs Second enumeration value to compare. - * - * Returns a Flags object with XORed states from the two enumeration values. - * In this case, two flags will be enabled if both the enumeration values are different. - */ - template - constexpr std::enable_if_t::value, Flags> operator^(E lhs, E rhs) - { - return Flags(lhs) ^ rhs; - } -} - -/*! -* \brief Override binary NOT operator on enum to turns into a Flags object. -* \return A Flags object with reversed bits. -* -* \param lhs Enumeration value to reverse. -* -* Returns a Flags object with all state enabled except for the enum one. -*/ -template -constexpr std::enable_if_t::value, Nz::Flags> operator~(E lhs) -{ - return ~Nz::Flags(lhs); -} - -/*! -* \brief Override binary OR operator on enum to turns into a Flags object. -* \return A Flags object with combined enum states. -* -* \param lhs First enumeration value to combine. -* \param rhs Second enumeration value to combine. -* -* Returns a Flags object with combined states from the two enumeration values. -*/ -template -constexpr std::enable_if_t::value, Nz::Flags> operator|(E lhs, E rhs) -{ - return Nz::Flags(lhs) | rhs; -} - -/*! -* \brief Override binary AND operator on enum to turns into a Flags object. -* \return A Flags object with compare enum states. -* -* \param lhs First enumeration value to compare. -* \param rhs Second enumeration value to compare. -* -* Returns a Flags object with compared states from the two enumeration values. -* In this case, only one flag will be enabled if both enumeration values are the same. -*/ -template -constexpr std::enable_if_t::value, Nz::Flags> operator&(E lhs, E rhs) -{ - return Nz::Flags(lhs) & rhs; -} - -/*! -* \brief Override binary XOR operator on enum to turns into a Flags object. -* \return A Flags object with XORed enum states. -* -* \param lhs First enumeration value to compare. -* \param rhs Second enumeration value to compare. -* -* Returns a Flags object with XORed states from the two enumeration values. -* In this case, two flags will be enabled if both the enumeration values are different. -*/ -template -constexpr std::enable_if_t::value, Nz::Flags> operator^(E lhs, E rhs) -{ - return Nz::Flags(lhs) ^ rhs; } #include