From fd09f1471ec419c8a10cbca5227807ea981bcdf1 Mon Sep 17 00:00:00 2001 From: GPUCode Date: Sat, 4 Feb 2023 19:01:57 +0200 Subject: [PATCH] common: Make equality operators explicit for Rectangle --- src/common/math_util.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/common/math_util.h b/src/common/math_util.h index eec4d8e65..c002e3450 100644 --- a/src/common/math_util.h +++ b/src/common/math_util.h @@ -24,8 +24,6 @@ struct Rectangle { constexpr Rectangle(T left, T top, T right, T bottom) : left(left), top(top), right(right), bottom(bottom) {} - constexpr auto operator<=>(const Rectangle&) const = default; - constexpr void operator*=(const T value) { left *= value; top *= value; @@ -33,10 +31,19 @@ struct Rectangle { bottom *= value; } - [[nodiscard]] constexpr Rectangle operator*(const T value) const { + [[nodiscard]] constexpr bool operator==(const Rectangle& rhs) const { + return (left == rhs.left) && (top == rhs.top) && (right == rhs.right) && + (bottom == rhs.bottom); + } + + [[nodiscard]] constexpr bool operator!=(const Rectangle& rhs) const { + return !operator==(rhs); + } + + [[nodiscard]] constexpr Rectangle operator*(const T value) const { return Rectangle{left * value, top * value, right * value, bottom * value}; } - [[nodiscard]] constexpr Rectangle operator/(const T value) const { + [[nodiscard]] constexpr Rectangle operator/(const T value) const { return Rectangle{left / value, top / value, right / value, bottom / value}; } [[nodiscard]] constexpr T GetWidth() const {