mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-08-03 10:55:57 -04:00
Move Rect and Point comparison operators out of classes
This commit is contained in:
parent
95142b065c
commit
a63cdde38f
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user