summaryrefslogtreecommitdiff
path: root/src/size.hh
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2026-01-02 22:42:31 +0100
committerJoel Klinghed <the_jk@spawned.biz>2026-01-02 22:42:31 +0100
commit6ed8f5151719fbc14ec0ac6d28a346d1f74cf2ca (patch)
treeebe7588e89e1aa2ae5376acf85f3a3a7b2ec7e10 /src/size.hh
Initial commitHEADmain
Diffstat (limited to 'src/size.hh')
-rw-r--r--src/size.hh30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/size.hh b/src/size.hh
new file mode 100644
index 0000000..8fcc53f
--- /dev/null
+++ b/src/size.hh
@@ -0,0 +1,30 @@
+#ifndef SIZE_HH
+#define SIZE_HH
+
+#include <compare>
+#include <cstdint>
+
+struct Size final {
+ Size() : width(0), height(0) {}
+ Size(uint32_t width, uint32_t height) : width(width), height(height) {}
+
+ bool empty() const { return width == 0 || height == 0; }
+
+ operator bool() const { return !empty(); }
+
+ std::strong_ordering operator<=>(Size const& other) const {
+ if (empty()) {
+ return other.empty() ? std::strong_ordering::equal
+ : std::strong_ordering::less;
+ }
+ if (other.empty())
+ return std::strong_ordering::greater;
+ auto ret = width <=> other.width;
+ return ret == std::strong_ordering::equal ? height <=> other.height : ret;
+ }
+
+ uint32_t width;
+ uint32_t height;
+};
+
+#endif // SIZE_HH