From 6403b5cff81e20a9a0bb867a9aa4c769eb12618f Mon Sep 17 00:00:00 2001 From: Olivier Galibert Date: Sat, 11 Sep 2021 21:15:56 +0200 Subject: rectangles: Add operators & and | (intersection and union) from the existing &= and |= ones. --- src/lib/util/bitmap.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lib/util/bitmap.h b/src/lib/util/bitmap.h index 4deb2550329..1b8dee3b5b5 100644 --- a/src/lib/util/bitmap.h +++ b/src/lib/util/bitmap.h @@ -75,6 +75,20 @@ public: return *this; } + rectangle operator&(const rectangle &b) + { + rectangle a(*this); + a &= b; + return a; + } + + rectangle operator|(const rectangle &b) + { + rectangle a(*this); + a |= b; + return a; + } + // comparisons constexpr bool operator==(const rectangle &rhs) const { return min_x == rhs.min_x && max_x == rhs.max_x && min_y == rhs.min_y && max_y == rhs.max_y; } constexpr bool operator!=(const rectangle &rhs) const { return min_x != rhs.min_x || max_x != rhs.max_x || min_y != rhs.min_y || max_y != rhs.max_y; } -- cgit v1.2.3