summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Olivier Galibert <galibert@pobox.com>2021-09-11 21:15:56 +0200
committer Olivier Galibert <galibert@pobox.com>2021-09-11 21:21:18 +0200
commit6403b5cff81e20a9a0bb867a9aa4c769eb12618f (patch)
treef7542a6cc38fc31edac78c58682ac48bcb966501
parent378a6d6cd409607729072dfccea4b2a3c6df4f4d (diff)
rectangles: Add operators & and | (intersection and union) from the
existing &= and |= ones.
-rw-r--r--src/lib/util/bitmap.h14
1 files changed, 14 insertions, 0 deletions
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; }