diff --git a/SDL2pp/Point.hh b/SDL2pp/Point.hh index 5564c53..87123c1 100644 --- a/SDL2pp/Point.hh +++ b/SDL2pp/Point.hh @@ -103,30 +103,6 @@ public: //////////////////////////////////////////////////////////// Point& operator=(Point&&) noexcept = default; - //////////////////////////////////////////////////////////// - /// \brief Equality operator - /// - /// \param[in] other Point to compare to - /// - /// \returns True if two points are identical - /// - //////////////////////////////////////////////////////////// - constexpr bool operator==(const Point& other) const { - return x == other.x && y == other.y; - } - - //////////////////////////////////////////////////////////// - /// \brief Inequality operator - /// - /// \param[in] other Point to compare to - /// - /// \returns True if two points are not identical - /// - //////////////////////////////////////////////////////////// - constexpr bool operator!=(const Point& other) const { - return x != other.x || y != other.y; - } - //////////////////////////////////////////////////////////// /// \brief Get X coordinate of the point /// @@ -447,6 +423,43 @@ public: } +//////////////////////////////////////////////////////////// +/// \brief Equality operator for SDL2pp::Point +/// +/// \param[in] a First argument for comparison +/// \param[in] b Second argument for comparison +/// +/// \returns True if two points are identical +/// +//////////////////////////////////////////////////////////// +constexpr bool operator==(const SDL2pp::Point&a, const SDL2pp::Point& b) { + return a.x == b.x && a.y == b.y; +} + +//////////////////////////////////////////////////////////// +/// \brief Inequality operator for SDL2pp::Point +/// +/// \param[in] a First argument for comparison +/// \param[in] b Second argument for comparison +/// +/// \returns True if two points are not identical +/// +//////////////////////////////////////////////////////////// +constexpr bool operator!=(const SDL2pp::Point& a, const SDL2pp::Point& b) { + return !(a == b); +} + +//////////////////////////////////////////////////////////// +/// \brief Less-than operator for SDL2pp::Point +/// +/// \param[in] a First argument for comparison +/// \param[in] b Second argument for comparison +/// +/// \returns True if a < b +/// +//////////////////////////////////////////////////////////// +bool operator<(const SDL2pp::Point& a, const SDL2pp::Point& b); + //////////////////////////////////////////////////////////// /// \brief Stream output operator overload for SDL2pp::Point /// @@ -458,15 +471,4 @@ public: //////////////////////////////////////////////////////////// std::ostream& operator<<(std::ostream& stream, const SDL2pp::Point& point); -//////////////////////////////////////////////////////////// -/// \brief Less-than operator for SDL2pp::Point -/// -/// \param[in] a First comparison argument -/// \param[in] b Second comparison argument -/// -/// \returns true if a < b -/// -//////////////////////////////////////////////////////////// -bool operator<(const SDL2pp::Point& a, const SDL2pp::Point& b); - #endif diff --git a/SDL2pp/Rect.hh b/SDL2pp/Rect.hh index b1ef101..0d1252d 100644 --- a/SDL2pp/Rect.hh +++ b/SDL2pp/Rect.hh @@ -162,32 +162,6 @@ public: //////////////////////////////////////////////////////////// Rect& operator=(Rect&&) noexcept = default; - //////////////////////////////////////////////////////////// - /// \brief Equality operator - /// - /// \param[in] other Rect to compare to - /// - /// \returns True if two rectangles are identical - /// - //////////////////////////////////////////////////////////// - constexpr bool operator==(const Rect& other) const { - return x == other.x && y == other.y && - w == other.w && h == other.h; - } - - //////////////////////////////////////////////////////////// - /// \brief Inequality operator - /// - /// \param[in] other Rect to compare to - /// - /// \returns True if two rectangles are not identical - /// - //////////////////////////////////////////////////////////// - constexpr bool operator!=(const Rect& other) const { - return x != other.x || y != other.y || - w != other.w || h != other.h; - } - //////////////////////////////////////////////////////////// /// \brief Get X coordinate of the rect corner /// @@ -523,6 +497,43 @@ public: } +//////////////////////////////////////////////////////////// +/// \brief Equality operator for SDL2pp::Rect +/// +/// \param[in] a First argument for comparison +/// \param[in] b Second argument for comparison +/// +/// \returns True if two rectangles are identical +/// +//////////////////////////////////////////////////////////// +constexpr bool operator==(const SDL2pp::Rect& a, const SDL2pp::Rect& b) { + return a.x == b.x && a.y == b.y && a.w == b.w && a.h == b.h; +} + +//////////////////////////////////////////////////////////// +/// \brief Inequality operator for SDL2pp::Rect +/// +/// \param[in] a First argument for comparison +/// \param[in] b Second argument for comparison +/// +/// \returns True if two rectangles are not identical +/// +//////////////////////////////////////////////////////////// +constexpr bool operator!=(const SDL2pp::Rect& a, const SDL2pp::Rect& b) { + return !(a == b); +} + +//////////////////////////////////////////////////////////// +/// \brief Less-than operator for SDL2pp::Rect +/// +/// \param[in] a First argument for comparison +/// \param[in] b Second argument for comparison +/// +/// \returns True if a < b +/// +//////////////////////////////////////////////////////////// +bool operator<(const SDL2pp::Rect& a, const SDL2pp::Rect& b); + //////////////////////////////////////////////////////////// /// \brief Stream output operator overload for SDL2pp::Rect /// @@ -534,15 +545,4 @@ public: //////////////////////////////////////////////////////////// std::ostream& operator<<(std::ostream& stream, const SDL2pp::Rect& rect); -//////////////////////////////////////////////////////////// -/// \brief Less-than operator for SDL2pp::Rect -/// -/// \param[in] a First comparison argument -/// \param[in] b Second comparison argument -/// -/// \returns true if a < b -/// -//////////////////////////////////////////////////////////// -bool operator<(const SDL2pp::Rect& a, const SDL2pp::Rect& b); - #endif