Skip to content

Commit 5c0f966

Browse files
committed
Use default comparisons from C++20
1 parent 580c500 commit 5c0f966

File tree

10 files changed

+13
-120
lines changed

10 files changed

+13
-120
lines changed

common/include/common/utils/list-utils.h

+1-14
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ class SinglyLinkedList
4646
return current == rhs.current;
4747
}
4848

49-
bool operator!=(const self_type& rhs) const
50-
{
51-
return !(*this == rhs);
52-
}
53-
5449
reference operator*() const
5550
{
5651
return *current;
@@ -117,15 +112,7 @@ class DoublyLinkedList
117112
return copy;
118113
}
119114

120-
bool operator==(const self_type& rhs) const
121-
{
122-
return current == rhs.current;
123-
}
124-
125-
bool operator!=(const self_type& rhs) const
126-
{
127-
return !(*this == rhs);
128-
}
115+
bool operator==(const self_type& rhs) const = default;
129116

130117
reference operator*() const
131118
{

editor_patch/mfc_types.h

-5
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ struct CString
3131
{
3232
return std::strcmp(m_pchData, s) == 0;
3333
}
34-
35-
bool operator!=(const char* s) const
36-
{
37-
return !(*this == s);
38-
}
3934
};
4035

4136
inline HWND WndToHandle(CWnd* wnd)

game_patch/graphics/d3d11/gr_d3d11_dynamic_geometry.h

+1-12
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,7 @@ namespace df::gr::d3d11
3939
};
4040
ID3D11PixelShader* pixel_shader = nullptr;
4141

42-
bool operator==(const State& other) const
43-
{
44-
return primitive_topology == other.primitive_topology &&
45-
textures == other.textures &&
46-
mode == other.mode &&
47-
pixel_shader == other.pixel_shader;
48-
}
49-
50-
bool operator!=(const State& other) const
51-
{
52-
return !(*this == other);
53-
}
42+
bool operator==(const State& other) const = default;
5443
};
5544

5645
std::tuple<GpuTransformedVertex*, rf::ushort*, rf::ushort> setup(int num_vert, int num_ind, const State& state)

game_patch/multi/multi_ban.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ class IpRange
2323
mask_{mask}
2424
{}
2525

26-
bool operator==(const IpRange& other)
27-
{
28-
return ip_ == other.ip_ && mask_ == other.mask_;
29-
}
26+
bool operator==(const IpRange& other) const = default;
3027

3128
bool matches(unsigned ip)
3229
{

game_patch/rf/gr/gr.h

+2-18
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,7 @@ namespace rf::gr
2626
this->alpha = a;
2727
}
2828

29-
bool operator==(const Color& other) const
30-
{
31-
return red == other.red && green == other.green && blue == other.blue && alpha == other.alpha;
32-
}
33-
34-
bool operator!=(const Color& other) const
35-
{
36-
return !(*this == other);
37-
}
29+
bool operator==(const Color& other) const = default;
3830
};
3931

4032
struct BaseVertex
@@ -141,15 +133,7 @@ namespace rf::gr
141133
value((ts << ts_shift) | (cs << cs_shift) | (as << as_shift) | (ab << ab_shift) | (zbt << zbt_shift) | (ft << ft_shift))
142134
{}
143135

144-
[[nodiscard]] bool operator==(const Mode& other) const
145-
{
146-
return value == other.value;
147-
}
148-
149-
[[nodiscard]] bool operator!=(const Mode& other) const
150-
{
151-
return value != other.value;
152-
}
136+
[[nodiscard]] bool operator==(const Mode& other) const = default;
153137

154138
operator int() const
155139
{

game_patch/rf/math/matrix.h

+2-18
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,7 @@ namespace rf
1111
Vector3 uvec;
1212
Vector3 fvec;
1313

14-
bool operator==(const Matrix3& other) const
15-
{
16-
return rvec == other.rvec && uvec == other.uvec && fvec == other.fvec;
17-
}
18-
19-
bool operator!=(const Matrix3& other) const
20-
{
21-
return !(*this == other);
22-
}
14+
bool operator==(const Matrix3& other) const = default;
2315

2416
void make_identity()
2517
{
@@ -40,15 +32,7 @@ namespace rf
4032
Matrix3 orient;
4133
Vector3 origin;
4234

43-
bool operator==(const Matrix43& other) const
44-
{
45-
return orient == other.orient && origin == other.origin;
46-
}
47-
48-
bool operator!=(const Matrix43& other) const
49-
{
50-
return !(*this == other);
51-
}
35+
bool operator==(const Matrix43& other) const = default;
5236

5337
Matrix43 operator*(const Matrix43& other) const
5438
{

game_patch/rf/math/vector.h

+2-18
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,7 @@ namespace rf
1414
Vector3() = default;
1515
Vector3(float x, float y, float z) : x(x), y(y), z(z) {}
1616

17-
bool operator==(const Vector3& other) const
18-
{
19-
return x == other.x && y == other.y && z == other.z;
20-
}
21-
22-
bool operator!=(const Vector3& other) const
23-
{
24-
return !(*this == other);
25-
}
17+
bool operator==(const Vector3& other) const = default;
2618

2719
Vector3& operator+=(const Vector3& other)
2820
{
@@ -175,15 +167,7 @@ namespace rf
175167
float x = 0.0f;
176168
float y = 0.0f;
177169

178-
bool operator==(const Vector2& other) const
179-
{
180-
return x == other.x && y == other.y;
181-
}
182-
183-
bool operator!=(const Vector2& other) const
184-
{
185-
return !(*this == other);
186-
}
170+
bool operator==(const Vector2& other) const = default;
187171
};
188172

189173
static auto& vec2_zero_vector = addr_as_ref<Vector2>(0x0173C370);

game_patch/rf/multi.h

+1-9
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,7 @@ namespace rf
1919
uint32_t ip_addr;
2020
uint16_t port;
2121

22-
bool operator==(const NetAddr &other) const
23-
{
24-
return ip_addr == other.ip_addr && port == other.port;
25-
}
26-
27-
bool operator!=(const NetAddr &other) const
28-
{
29-
return !(*this == other);
30-
}
22+
bool operator==(const NetAddr &other) const = default;
3123
};
3224
static_assert(sizeof(NetAddr) == 0x8);
3325

game_patch/rf/os/linklist.h

+2-18
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,7 @@ namespace rf
3434
return copy;
3535
}
3636

37-
bool operator==(Iterator& other) const
38-
{
39-
return current_ == other.current_;
40-
}
41-
42-
bool operator!=(Iterator& other) const
43-
{
44-
return current_ != other.current_;
45-
}
37+
bool operator==(const Iterator& other) const = default;
4638
};
4739

4840
class ConstIterator
@@ -70,15 +62,7 @@ namespace rf
7062
return copy;
7163
}
7264

73-
bool operator==(ConstIterator& other) const
74-
{
75-
return current_ == other.current_;
76-
}
77-
78-
bool operator!=(ConstIterator& other) const
79-
{
80-
return current_ != other.current_;
81-
}
65+
bool operator==(const ConstIterator& other) const = default;
8266
};
8367

8468
[[nodiscard]] T* first()

patch_common/include/patch_common/AsmWriter.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ class AsmReg
1717
reg_num(reg_num), size(size)
1818
{}
1919

20-
constexpr bool operator==(const AsmReg& other) const
21-
{
22-
return reg_num == other.reg_num && size == other.size;
23-
}
20+
constexpr bool operator==(const AsmReg& other) const = default;
2421
};
2522

2623
struct AsmReg32 : public AsmReg

0 commit comments

Comments
 (0)