2
3
4
5
6
7
8
9
10
11
12
13
14
15
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) {}
59inline constexpr bool operator == (Point<T>
const& lhs, Point<T>
const& rhs)
61 return lhs.x == rhs.x && lhs.y == rhs.y;
65inline constexpr bool operator != (Point<T>
const& lhs, Point<T>
const& rhs)
67 return lhs.x != rhs.x || lhs.y != rhs.y;
71inline constexpr Point<T>
operator+(Point<T> lhs, DeltaX<T> rhs) {
return{lhs.x + rhs, lhs.y}; }
73inline constexpr Point<T>
operator+(Point<T> lhs, DeltaY<T> rhs) {
return{lhs.x, lhs.y + rhs}; }
76inline constexpr Point<T>
operator-(Point<T> lhs, DeltaX<T> rhs) {
return{lhs.x - rhs, lhs.y}; }
78inline constexpr Point<T>
operator-(Point<T> lhs, DeltaY<T> rhs) {
return{lhs.x, lhs.y - rhs}; }
81inline Point<T>&
operator+=(Point<T>& lhs, DeltaX<T> rhs) { lhs.x += rhs;
return lhs; }
83inline Point<T>&
operator+=(Point<T>& lhs, DeltaY<T> rhs) { lhs.y += rhs;
return lhs; }
86inline Point<T>&
operator-=(Point<T>& lhs, DeltaX<T> rhs) { lhs.x -= rhs;
return lhs; }
88inline Point<T>&
operator-=(Point<T>& lhs, DeltaY<T> rhs) { lhs.y -= rhs;
return lhs; }
91std::ostream& operator<<(std::ostream& out, Point<T>
const& value)
93 out << value.x <<
", " << value.y;
Point< T > & operator+=(Point< T > &lhs, DeltaX< T > rhs)
Definition point.h:81
constexpr bool operator==(Point< T > const &lhs, Point< T > const &rhs)
Definition point.h:59
Point< T > & operator-=(Point< T > &lhs, DeltaX< T > rhs)
Definition point.h:86
constexpr Point< T > operator-(Point< T > lhs, DeltaX< T > rhs)
Definition point.h:76
constexpr bool operator!=(Point< T > const &lhs, Point< T > const &rhs)
Definition point.h:65
constexpr Point< T > operator+(Point< T > lhs, DeltaX< T > rhs)
Definition point.h:71
Basic geometry types. Types for dimensions, displacements, etc. and the operations that they support.
Definition size.h:27
X< T > x
Definition point.h:54
constexpr Point(Point< U > const &other) noexcept
Definition point.h:45
Y< T > y
Definition point.h:55
Point & operator=(Point const &)=default
constexpr Point()=default
constexpr Point(Point const &)=default
constexpr Point(XType &&x, YType &&y)
Definition point.h:52