1 #pragma once
2
3 namespace mapbox {
4 namespace geometry {
5
6 template <typename T>
operator +(point<T> const & lhs,point<T> const & rhs)7 point<T> operator+(point<T> const& lhs, point<T> const& rhs)
8 {
9 return point<T>(lhs.x + rhs.x, lhs.y + rhs.y);
10 }
11
12 template <typename T>
operator +(point<T> const & lhs,T const & rhs)13 point<T> operator+(point<T> const& lhs, T const& rhs)
14 {
15 return point<T>(lhs.x + rhs, lhs.y + rhs);
16 }
17
18 template <typename T>
operator -(point<T> const & lhs,point<T> const & rhs)19 point<T> operator-(point<T> const& lhs, point<T> const& rhs)
20 {
21 return point<T>(lhs.x - rhs.x, lhs.y - rhs.y);
22 }
23
24 template <typename T>
operator -(point<T> const & lhs,T const & rhs)25 point<T> operator-(point<T> const& lhs, T const& rhs)
26 {
27 return point<T>(lhs.x - rhs, lhs.y - rhs);
28 }
29
30 template <typename T>
operator *(point<T> const & lhs,point<T> const & rhs)31 point<T> operator*(point<T> const& lhs, point<T> const& rhs)
32 {
33 return point<T>(lhs.x * rhs.x, lhs.y * rhs.y);
34 }
35
36 template <typename T>
operator *(point<T> const & lhs,T const & rhs)37 point<T> operator*(point<T> const& lhs, T const& rhs)
38 {
39 return point<T>(lhs.x * rhs, lhs.y * rhs);
40 }
41
42 template <typename T>
operator /(point<T> const & lhs,point<T> const & rhs)43 point<T> operator/(point<T> const& lhs, point<T> const& rhs)
44 {
45 return point<T>(lhs.x / rhs.x, lhs.y / rhs.y);
46 }
47
48 template <typename T>
operator /(point<T> const & lhs,T const & rhs)49 point<T> operator/(point<T> const& lhs, T const& rhs)
50 {
51 return point<T>(lhs.x / rhs, lhs.y / rhs);
52 }
53
54 template <typename T>
operator +=(point<T> & lhs,point<T> const & rhs)55 point<T>& operator+=(point<T>& lhs, point<T> const& rhs)
56 {
57 lhs.x += rhs.x;
58 lhs.y += rhs.y;
59 return lhs;
60 }
61
62 template <typename T>
operator +=(point<T> & lhs,T const & rhs)63 point<T>& operator+=(point<T>& lhs, T const& rhs)
64 {
65 lhs.x += rhs;
66 lhs.y += rhs;
67 return lhs;
68 }
69
70 template <typename T>
operator -=(point<T> & lhs,point<T> const & rhs)71 point<T>& operator-=(point<T>& lhs, point<T> const& rhs)
72 {
73 lhs.x -= rhs.x;
74 lhs.y -= rhs.y;
75 return lhs;
76 }
77
78 template <typename T>
operator -=(point<T> & lhs,T const & rhs)79 point<T>& operator-=(point<T>& lhs, T const& rhs)
80 {
81 lhs.x -= rhs;
82 lhs.y -= rhs;
83 return lhs;
84 }
85
86 template <typename T>
operator *=(point<T> & lhs,point<T> const & rhs)87 point<T>& operator*=(point<T>& lhs, point<T> const& rhs)
88 {
89 lhs.x *= rhs.x;
90 lhs.y *= rhs.y;
91 return lhs;
92 }
93
94 template <typename T>
operator *=(point<T> & lhs,T const & rhs)95 point<T>& operator*=(point<T>& lhs, T const& rhs)
96 {
97 lhs.x *= rhs;
98 lhs.y *= rhs;
99 return lhs;
100 }
101
102 template <typename T>
operator /=(point<T> & lhs,point<T> const & rhs)103 point<T>& operator/=(point<T>& lhs, point<T> const& rhs)
104 {
105 lhs.x /= rhs.x;
106 lhs.y /= rhs.y;
107 return lhs;
108 }
109
110 template <typename T>
operator /=(point<T> & lhs,T const & rhs)111 point<T>& operator/=(point<T>& lhs, T const& rhs)
112 {
113 lhs.x /= rhs;
114 lhs.y /= rhs;
115 return lhs;
116 }
117
118 } // namespace geometry
119 } // namespace mapbox
120