From 6ed8f5151719fbc14ec0ac6d28a346d1f74cf2ca Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Fri, 2 Jan 2026 22:42:31 +0100 Subject: Initial commit --- src/size.hh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/size.hh (limited to 'src/size.hh') 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 +#include + +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 -- cgit v1.2.3-70-g09d2