summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2021-01-22 15:12:37 -0500
committerAndreas Kling <kling@serenityos.org>2021-01-22 22:13:53 +0100
commit7278ff66051f9b71403c28521c3f07c11d4e8ff5 (patch)
treef16f06d34818f013b1065dab27c5b0ce9742d914 /Userland
parent67cda61b7f63935032b4e946f908df038ac51ff9 (diff)
downloadserenity-7278ff66051f9b71403c28521c3f07c11d4e8ff5.zip
LibGfx: Allow comparing Points, Sizes, and Rects of different type
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibGfx/Point.h8
-rw-r--r--Userland/Libraries/LibGfx/Rect.h8
-rw-r--r--Userland/Libraries/LibGfx/Size.h8
3 files changed, 15 insertions, 9 deletions
diff --git a/Userland/Libraries/LibGfx/Point.h b/Userland/Libraries/LibGfx/Point.h
index 753d04055a..be6a71e149 100644
--- a/Userland/Libraries/LibGfx/Point.h
+++ b/Userland/Libraries/LibGfx/Point.h
@@ -107,12 +107,14 @@ public:
return point;
}
- bool operator==(const Point<T>& other) const
+ template<class U>
+ bool operator==(const Point<U>& other) const
{
- return m_x == other.m_x && m_y == other.m_y;
+ return x() == other.x() && y() == other.y();
}
- bool operator!=(const Point<T>& other) const
+ template<class U>
+ bool operator!=(const Point<U>& other) const
{
return !(*this == other);
}
diff --git a/Userland/Libraries/LibGfx/Rect.h b/Userland/Libraries/LibGfx/Rect.h
index f54ff43fbf..e9ad4b136e 100644
--- a/Userland/Libraries/LibGfx/Rect.h
+++ b/Userland/Libraries/LibGfx/Rect.h
@@ -354,12 +354,14 @@ public:
Vector<Rect<T>, 4> shatter(const Rect<T>& hammer) const;
- bool operator==(const Rect<T>& other) const
+ template<class U>
+ bool operator==(const Rect<U>& other) const
{
- return m_location == other.m_location && m_size == other.m_size;
+ return location() == other.location() && size() == other.size();
}
- bool operator!=(const Rect<T>& other) const
+ template<class U>
+ bool operator!=(const Rect<U>& other) const
{
return !(*this == other);
}
diff --git a/Userland/Libraries/LibGfx/Size.h b/Userland/Libraries/LibGfx/Size.h
index 7b0cbe96fc..67321a4a2d 100644
--- a/Userland/Libraries/LibGfx/Size.h
+++ b/Userland/Libraries/LibGfx/Size.h
@@ -74,12 +74,14 @@ public:
return other.m_width <= m_width && other.m_height <= m_height;
}
- bool operator==(const Size<T>& other) const
+ template<class U>
+ bool operator==(const Size<U>& other) const
{
- return m_width == other.m_width && m_height == other.m_height;
+ return width() == other.width() && height() == other.height();
}
- bool operator!=(const Size<T>& other) const
+ template<class U>
+ bool operator!=(const Size<U>& other) const
{
return !(*this == other);
}