From 983d5165878df0190964a8f903c24055f9144612 Mon Sep 17 00:00:00 2001 From: Neil Date: Mon, 18 Mar 2019 19:22:38 +1100 Subject: Add some operators to Point to simplify client code. --- include/Platform.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/Platform.h b/include/Platform.h index c1924eda5..7a621c65e 100644 --- a/include/Platform.h +++ b/include/Platform.h @@ -108,6 +108,18 @@ public: return Point(static_cast(x_), static_cast(y_)); } + bool operator!=(Point other) const noexcept { + return (x != other.x) || (y != other.y); + } + + Point operator+(Point other) const noexcept { + return Point(x + other.x, y + other.y); + } + + Point operator-(Point other) const noexcept { + return Point(x - other.x, y - other.y); + } + // Other automatically defined methods (assignment, copy constructor, destructor) are fine }; -- cgit v1.2.3