17 #ifndef MIR_GEOMETRY_POINT_H_
18 #define MIR_GEOMETRY_POINT_H_
41 constexpr Point(Point
const&) =
default;
45 explicit constexpr Point(Point<U>
const& other)
noexcept
51 template<
typename XType,
typename YType>
52 constexpr Point(XType&& x, YType&& y) :
x(
x),
y(
y) {}
59 inline constexpr bool operator == (Point<T>
const& lhs, Point<T>
const& rhs)
61 return lhs.x == rhs.x && lhs.y == rhs.y;
65 inline constexpr bool operator != (Point<T>
const& lhs, Point<T>
const& rhs)
67 return lhs.x != rhs.x || lhs.y != rhs.y;
71 inline constexpr Point<T>
operator+(Point<T> lhs, DeltaX<T> rhs) {
return{lhs.x + rhs, lhs.y}; }
73 inline constexpr Point<T>
operator+(Point<T> lhs, DeltaY<T> rhs) {
return{lhs.x, lhs.y + rhs}; }
76 inline constexpr Point<T>
operator-(Point<T> lhs, DeltaX<T> rhs) {
return{lhs.x - rhs, lhs.y}; }
78 inline constexpr Point<T>
operator-(Point<T> lhs, DeltaY<T> rhs) {
return{lhs.x, lhs.y - rhs}; }
81 inline Point<T>&
operator+=(Point<T>& lhs, DeltaX<T> rhs) { lhs.x += rhs;
return lhs; }
83 inline Point<T>&
operator+=(Point<T>& lhs, DeltaY<T> rhs) { lhs.y += rhs;
return lhs; }
86 inline Point<T>&
operator-=(Point<T>& lhs, DeltaX<T> rhs) { lhs.x -= rhs;
return lhs; }
88 inline Point<T>&
operator-=(Point<T>& lhs, DeltaY<T> rhs) { lhs.y -= rhs;
return lhs; }
91 std::ostream& operator<<(std::ostream& out, Point<T>
const& value)
93 out << value.x <<
", " << value.y;