Skip to content

Commit 246c9e8

Browse files
committed
Default comparisons
1 parent b0ba2c9 commit 246c9e8

File tree

12 files changed

+6
-297
lines changed

12 files changed

+6
-297
lines changed

src/modm/math/geometry/vector.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,7 @@ namespace modm
6464
Vector(const Matrix<T, N, 1> &rhs);
6565
Vector& operator = (const Matrix<T, N, 1> &rhs);
6666

67-
bool operator == (const Vector &rhs) const;
68-
bool operator != (const Vector &rhs) const;
69-
bool operator < (const Vector &rhs) const;
70-
bool operator <= (const Vector &rhs) const;
71-
bool operator > (const Vector &rhs) const;
72-
bool operator >= (const Vector &rhs) const;
67+
auto operator<=>(const Vector &) const = default;
7368

7469
T& operator [] (std::size_t index);
7570
const T& operator [] (std::size_t index) const;

src/modm/math/geometry/vector1.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,7 @@ namespace modm
5454

5555
Vector& operator = (const Matrix<T, 1, 1> &rhs);
5656

57-
bool operator == (const Vector &rhs) const;
58-
bool operator != (const Vector &rhs) const;
59-
bool operator < (const Vector &rhs) const;
60-
bool operator <= (const Vector &rhs) const;
61-
bool operator > (const Vector &rhs) const;
62-
bool operator >= (const Vector &rhs) const;
57+
auto operator<=>(const Vector &) const = default;
6358

6459
T& operator [] (std::size_t index);
6560
const T& operator [] (std::size_t index) const;

src/modm/math/geometry/vector1_impl.hpp

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -47,49 +47,6 @@ modm::Vector<T, 1>::operator = (const modm::Matrix<T, 1, 1> &rhs)
4747
return *this;
4848
}
4949

50-
// ----------------------------------------------------------------------------
51-
template<typename T>
52-
bool
53-
modm::Vector<T, 1>::operator == (const modm::Vector<T, 1> &rhs) const
54-
{
55-
return (rhs.x == x);
56-
}
57-
58-
template<typename T>
59-
bool
60-
modm::Vector<T, 1>::operator != (const modm::Vector<T, 1> &rhs) const
61-
{
62-
return (rhs.x != x);
63-
}
64-
65-
template<typename T>
66-
bool
67-
modm::Vector<T, 1>::operator < (const modm::Vector<T, 1> &rhs) const
68-
{
69-
return (x < rhs.x);
70-
}
71-
72-
template<typename T>
73-
bool
74-
modm::Vector<T, 1>::operator <= (const modm::Vector<T, 1> &rhs) const
75-
{
76-
return (x <= rhs.x);
77-
}
78-
79-
template<typename T>
80-
bool
81-
modm::Vector<T, 1>::operator > (const modm::Vector<T, 1> &rhs) const
82-
{
83-
return (x > rhs.x);
84-
}
85-
86-
template<typename T>
87-
bool
88-
modm::Vector<T, 1>::operator >= (const modm::Vector<T, 1> &rhs) const
89-
{
90-
return (x >= rhs.x);
91-
}
92-
9350
// ----------------------------------------------------------------------------
9451
template<typename T>
9552
const T&

src/modm/math/geometry/vector2.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,7 @@ namespace modm
224224

225225
Vector& operator = (const Matrix<T, 2, 1> &rhs);
226226

227-
bool operator == (const Vector &rhs) const;
228-
bool operator != (const Vector &rhs) const;
229-
bool operator < (const Vector &rhs) const;
230-
bool operator <= (const Vector &rhs) const;
231-
bool operator > (const Vector &rhs) const;
232-
bool operator >= (const Vector &rhs) const;
227+
auto operator<=>(const Vector&) const = default;
233228

234229
T& operator [] (std::size_t index);
235230
const T& operator [] (std::size_t index) const;

src/modm/math/geometry/vector2_impl.hpp

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -264,45 +264,6 @@ modm::Vector<T, 2>& modm::Vector<T, 2>::operator = (const modm::Matrix<T, 2, 1>
264264
return *this;
265265
}
266266

267-
// ----------------------------------------------------------------------------
268-
template<typename T>
269-
bool modm::Vector<T, 2>::operator == (const modm::Vector<T, 2> &rhs) const
270-
{
271-
return ((rhs.x == x) && (rhs.y == y));
272-
}
273-
274-
template<typename T>
275-
bool modm::Vector<T, 2>::operator != (const modm::Vector<T, 2> &rhs) const
276-
{
277-
return ((rhs.x != x) || (rhs.y != y));
278-
}
279-
280-
template<typename T>
281-
bool modm::Vector<T, 2>::operator < (const modm::Vector<T, 2> &rhs) const
282-
{
283-
return (x < rhs.x) || ((x == rhs.x) && (y < rhs.y));
284-
}
285-
286-
template<typename T>
287-
bool modm::Vector<T, 2>::operator <= (const modm::Vector<T, 2> &rhs) const
288-
{
289-
return (x < rhs.x) || ((x == rhs.x) && (y <= rhs.y));
290-
}
291-
292-
template<typename T>
293-
bool
294-
modm::Vector<T, 2>::operator > (const modm::Vector<T, 2> &rhs) const
295-
{
296-
return (x > rhs.x) || ((x == rhs.x) && (y > rhs.y));
297-
}
298-
299-
template<typename T>
300-
bool
301-
modm::Vector<T, 2>::operator >= (const modm::Vector<T, 2> &rhs) const
302-
{
303-
return (x > rhs.x) || ((x == rhs.x) && (y >= rhs.y));
304-
}
305-
306267
// ----------------------------------------------------------------------------
307268
template<typename T>
308269
const T&

src/modm/math/geometry/vector3.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,7 @@ namespace modm
9797

9898
Vector& operator = (const Matrix<T, 3, 1> &rhs);
9999

100-
bool operator == (const Vector &rhs) const;
101-
bool operator != (const Vector &rhs) const;
102-
bool operator < (const Vector &rhs) const;
103-
bool operator <= (const Vector &rhs) const;
104-
bool operator > (const Vector &rhs) const;
105-
bool operator >= (const Vector &rhs) const;
100+
auto operator<=>(const Vector&) const = default;
106101

107102
T& operator [] (std::size_t index);
108103
const T& operator [] (std::size_t index) const;

src/modm/math/geometry/vector3_impl.hpp

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -144,49 +144,6 @@ modm::Vector<T, 3>::operator = (const modm::Matrix<T, 3, 1> &rhs)
144144
return *this;
145145
}
146146

147-
// ----------------------------------------------------------------------------
148-
template<typename T>
149-
bool
150-
modm::Vector<T, 3>::operator == (const Vector &rhs) const
151-
{
152-
return (rhs.x == x) && (rhs.y == y) && (rhs.z == z);
153-
}
154-
155-
template<typename T>
156-
bool
157-
modm::Vector<T, 3>::operator != (const Vector &rhs) const
158-
{
159-
return (rhs.x != x) || (rhs.y != y) || (rhs.z != z);
160-
}
161-
162-
template<typename T>
163-
bool
164-
modm::Vector<T, 3>::operator < (const Vector &rhs) const
165-
{
166-
return (x < rhs.x) || ((x == rhs.x) && ((y < rhs.y) || ((y == rhs.y) && (z < rhs.z))));
167-
}
168-
169-
template<typename T>
170-
bool
171-
modm::Vector<T, 3>::operator <= (const Vector &rhs) const
172-
{
173-
return (x < rhs.x) || ((x == rhs.x) && ((y < rhs.y) || ((y == rhs.y) && (z <= rhs.z))));
174-
}
175-
176-
template<typename T>
177-
bool
178-
modm::Vector<T, 3>::operator > (const Vector &rhs) const
179-
{
180-
return (x > rhs.x) || ((x == rhs.x) && ((y > rhs.y) || ((y == rhs.y) && (z > rhs.z))));
181-
}
182-
183-
template<typename T>
184-
bool
185-
modm::Vector<T, 3>::operator >= (const Vector &rhs) const
186-
{
187-
return (x > rhs.x) || ((x == rhs.x) && ((y > rhs.y) || ((y == rhs.y) && (z >= rhs.z))));
188-
}
189-
190147
// ----------------------------------------------------------------------------
191148
template<typename T>
192149
const T&

src/modm/math/geometry/vector4.hpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ namespace modm
9090
inline void
9191
set(const T& x, const T& y, const T& z, const T& w);
9292

93-
9493
inline void
9594
setX(const T& value);
9695

@@ -116,15 +115,9 @@ namespace modm
116115
inline const T&
117116
getW() const;
118117

119-
120118
Vector& operator = (const Matrix<T, 4, 1> &rhs);
121119

122-
bool operator == (const Vector &rhs) const;
123-
bool operator != (const Vector &rhs) const;
124-
bool operator < (const Vector &rhs) const;
125-
bool operator <= (const Vector &rhs) const;
126-
bool operator > (const Vector &rhs) const;
127-
bool operator >= (const Vector &rhs) const;
120+
auto operator<=>(const Vector&) const = default;
128121

129122
T& operator [] (std::size_t index);
130123
const T& operator [] (std::size_t index) const;

src/modm/math/geometry/vector4_impl.hpp

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -231,49 +231,6 @@ modm::Vector<T, 4>::operator = (const modm::Matrix<T, 4, 1> &rhs)
231231
return *this;
232232
}
233233

234-
// ----------------------------------------------------------------------------
235-
template<typename T>
236-
bool
237-
modm::Vector<T, 4>::operator == (const modm::Vector<T, 4> &rhs) const
238-
{
239-
return (rhs.x == x) && (rhs.y == y) && (rhs.z == z) && (rhs.w == w);
240-
}
241-
242-
template<typename T>
243-
bool
244-
modm::Vector<T, 4>::operator != (const modm::Vector<T, 4> &rhs) const
245-
{
246-
return (rhs.x != x) || (rhs.y != y) || (rhs.z != z) || (rhs.w != w);
247-
}
248-
249-
template<typename T>
250-
bool
251-
modm::Vector<T, 4>::operator < (const modm::Vector<T, 4> &rhs) const
252-
{
253-
return (x < rhs.x) || ((x == rhs.x) && ((y < rhs.y) || ((y == rhs.y) && ((z < rhs.z) || ((z == rhs.z) && (w < rhs.w))))));
254-
}
255-
256-
template<typename T>
257-
bool
258-
modm::Vector<T, 4>::operator <= (const modm::Vector<T, 4> &rhs) const
259-
{
260-
return (x < rhs.x) || ((x == rhs.x) && ((y < rhs.y) || ((y == rhs.y) && ((z < rhs.z) || ((z == rhs.z) && (w <= rhs.w))))));
261-
}
262-
263-
template<typename T>
264-
bool
265-
modm::Vector<T, 4>::operator > (const modm::Vector<T, 4> &rhs) const
266-
{
267-
return (x > rhs.x) || ((x == rhs.x) && ((y > rhs.y) || ((y == rhs.y) && ((z > rhs.z) || ((z == rhs.z) && (w > rhs.w))))));
268-
}
269-
270-
template<typename T>
271-
bool
272-
modm::Vector<T, 4>::operator >= (const modm::Vector<T, 4> &rhs) const
273-
{
274-
return (x > rhs.x) || ((x == rhs.x) && ((y > rhs.y) || ((y == rhs.y) && ((z > rhs.z) || ((z == rhs.z) && (w >= rhs.w))))));
275-
}
276-
277234
// ----------------------------------------------------------------------------
278235
template<typename T>
279236
const T&

src/modm/math/geometry/vector_impl.hpp

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -41,85 +41,6 @@ modm::Vector<T, N>::operator = (const modm::Matrix<T, N, 1> &rhs)
4141
return *this;
4242
}
4343

44-
// ----------------------------------------------------------------------------
45-
template<typename T, std::size_t N>
46-
bool
47-
modm::Vector<T, N>::operator == (const modm::Vector<T, N> &rhs) const
48-
{
49-
return memcmp(coords, rhs.coords, sizeof(T)*N) == 0;
50-
}
51-
52-
template<typename T, std::size_t N>
53-
bool
54-
modm::Vector<T, N>::operator != (const modm::Vector<T, N> &rhs) const
55-
{
56-
return memcmp(coords, rhs.coords, sizeof(T)*N) != 0;
57-
}
58-
59-
template<typename T, std::size_t N>
60-
bool
61-
modm::Vector<T, N>::operator < (const modm::Vector<T, N> &rhs) const
62-
{
63-
for (uint_fast8_t i = 0; i < N; ++i)
64-
{
65-
if ((*this)[i] < rhs[i]) {
66-
return true;
67-
}
68-
else if ((*this)[i] > rhs[i]) {
69-
return false;
70-
}
71-
}
72-
return false;
73-
}
74-
75-
template<typename T, std::size_t N>
76-
bool
77-
modm::Vector<T, N>::operator <= (const modm::Vector<T, N> &rhs) const
78-
{
79-
for (uint_fast8_t i = 0; i < N; ++i)
80-
{
81-
if ((*this)[i] < rhs[i]) {
82-
return true;
83-
}
84-
else if ((*this)[i] > rhs[i]) {
85-
return false;
86-
}
87-
}
88-
return true;
89-
}
90-
91-
template<typename T, std::size_t N>
92-
bool
93-
modm::Vector<T, N>::operator > (const modm::Vector<T, N> &rhs) const
94-
{
95-
for (uint_fast8_t i = 0; i < N; ++i)
96-
{
97-
if ((*this)[i] > rhs[i]) {
98-
return true;
99-
}
100-
else if ((*this)[i] < rhs[i]) {
101-
return false;
102-
}
103-
}
104-
return false;
105-
}
106-
107-
template<typename T, std::size_t N>
108-
bool
109-
modm::Vector<T, N>::operator >= (const modm::Vector<T, N> &rhs) const
110-
{
111-
for (uint_fast8_t i = 0; i < N; ++i)
112-
{
113-
if ((*this)[i] > rhs[i]) {
114-
return true;
115-
}
116-
else if ((*this)[i] < rhs[i]) {
117-
return false;
118-
}
119-
}
120-
return true;
121-
}
122-
12344
// ----------------------------------------------------------------------------
12445
template<typename T, std::size_t N>
12546
const T&

0 commit comments

Comments
 (0)