Use default version of operator== for some fxcrt classes
With C++20, switch to default comparisons.
Change-Id: I0aab9fde7250af4e8294d70f0ae189e3d2bfeec0
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/135130
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxcrt/cfx_datetime.cpp b/core/fxcrt/cfx_datetime.cpp
index 86d8e24..a91997b 100644
--- a/core/fxcrt/cfx_datetime.cpp
+++ b/core/fxcrt/cfx_datetime.cpp
@@ -99,10 +99,3 @@
}
return v;
}
-
-bool operator==(const CFX_DateTime& lhs, const CFX_DateTime& rhs) {
- return lhs.year_ == rhs.year_ && lhs.month_ == rhs.month_ &&
- lhs.day_ == rhs.day_ && lhs.hour_ == rhs.hour_ &&
- lhs.minute_ == rhs.minute_ && lhs.second_ == rhs.second_ &&
- lhs.millisecond_ == rhs.millisecond_;
-}
diff --git a/core/fxcrt/cfx_datetime.h b/core/fxcrt/cfx_datetime.h
index 66e35c2..9adc21b 100644
--- a/core/fxcrt/cfx_datetime.h
+++ b/core/fxcrt/cfx_datetime.h
@@ -72,7 +72,8 @@
uint16_t GetMillisecond() const { return millisecond_; }
int32_t GetDayOfWeek() const;
- friend bool operator==(const CFX_DateTime& lhs, const CFX_DateTime& rhs);
+ friend constexpr bool operator==(const CFX_DateTime&,
+ const CFX_DateTime&) = default;
private:
int32_t year_ = 0;
diff --git a/core/fxcrt/fx_coordinates.h b/core/fxcrt/fx_coordinates.h
index 4288aa8..8a03d13 100644
--- a/core/fxcrt/fx_coordinates.h
+++ b/core/fxcrt/fx_coordinates.h
@@ -20,10 +20,8 @@
CFX_PTemplate(const CFX_PTemplate& other) = default;
CFX_PTemplate& operator=(const CFX_PTemplate& other) = default;
- friend inline bool operator==(const CFX_PTemplate& lhs,
- const CFX_PTemplate& rhs) {
- return lhs.x == rhs.x && lhs.y == rhs.y;
- }
+ friend constexpr bool operator==(const CFX_PTemplate&,
+ const CFX_PTemplate&) = default;
CFX_PTemplate& operator+=(const CFX_PTemplate<BaseType>& obj) {
x += obj.x;
y += obj.y;
@@ -71,10 +69,8 @@
width = 0;
height = 0;
}
- friend inline bool operator==(const CFX_STemplate& lhs,
- const CFX_STemplate& rhs) {
- return lhs.width == rhs.width && lhs.height == rhs.height;
- }
+ friend constexpr bool operator==(const CFX_STemplate&,
+ const CFX_STemplate&) = default;
CFX_STemplate& operator+=(const CFX_STemplate<BaseType>& obj) {
width += obj.width;
height += obj.height;
@@ -166,10 +162,7 @@
bottom += dy;
}
- friend inline bool operator==(const FX_RECT& lhs, const FX_RECT& rhs) {
- return lhs.left == rhs.left && lhs.right == rhs.right &&
- lhs.top == rhs.top && lhs.bottom == rhs.bottom;
- }
+ friend constexpr bool operator==(const FX_RECT&, const FX_RECT&) = default;
bool Contains(int x, int y) const {
return x >= left && x < right && y >= top && y < bottom;
@@ -261,11 +254,8 @@
// Rounds LBRT values.
FX_RECT ToRoundedFxRect() const;
- friend inline bool operator==(const CFX_FloatRect& lhs,
- const CFX_FloatRect& rhs) {
- return lhs.left == rhs.left && lhs.right == rhs.right &&
- lhs.top == rhs.top && rhs.bottom == rhs.bottom;
- }
+ friend constexpr bool operator==(const CFX_FloatRect&,
+ const CFX_FloatRect&) = default;
float left = 0.0f;
float bottom = 0.0f;
@@ -408,10 +398,8 @@
rect.Intersect(*this);
return !rect.IsEmpty(fEpsilon);
}
- friend inline bool operator==(const CFX_RectF& rc1, const CFX_RectF& rc2) {
- return rc1.left == rc2.left && rc1.top == rc2.top &&
- rc1.width == rc2.width && rc1.height == rc2.height;
- }
+ friend constexpr bool operator==(const CFX_RectF&,
+ const CFX_RectF&) = default;
CFX_FloatRect ToFloatRect() const {
// Note, we flip top/bottom here because the CFX_FloatRect has the
@@ -451,10 +439,8 @@
CFX_Matrix& operator=(const CFX_Matrix& other) = default;
- friend inline bool operator==(const CFX_Matrix& lhs, const CFX_Matrix& rhs) {
- return lhs.a == rhs.a && lhs.b == rhs.b && lhs.c == rhs.c &&
- lhs.d == rhs.d && lhs.e == rhs.e && lhs.f == rhs.f;
- }
+ friend constexpr bool operator==(const CFX_Matrix&,
+ const CFX_Matrix&) = default;
CFX_Matrix operator*(const CFX_Matrix& right) const {
return CFX_Matrix(a * right.a + b * right.c, a * right.b + b * right.d,
diff --git a/core/fxcrt/mask.h b/core/fxcrt/mask.h
index a0dee51..0f9191a 100644
--- a/core/fxcrt/mask.h
+++ b/core/fxcrt/mask.h
@@ -92,9 +92,7 @@
val_ ^= that.val_;
return *this;
}
- friend inline bool operator==(const Mask& lhs, const Mask& rhs) {
- return lhs.val_ == rhs.val_;
- }
+ friend constexpr bool operator==(const Mask&, const Mask&) = default;
bool TestAll(const Mask& that) const {
return (val_ & that.val_) == that.val_;
}