diff options
Diffstat (limited to 'include/mbgl/util/size.hpp')
-rw-r--r-- | include/mbgl/util/size.hpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/include/mbgl/util/size.hpp b/include/mbgl/util/size.hpp new file mode 100644 index 0000000000..1af85bcff5 --- /dev/null +++ b/include/mbgl/util/size.hpp @@ -0,0 +1,32 @@ +#pragma once + +#include <cstdint> +#include <array> + +namespace mbgl { + +class Size { +public: + constexpr Size() : width(0), height(0) { + } + + constexpr Size(const uint32_t width_, const uint32_t height_) : width(width_), height(height_) { + } + + constexpr explicit operator bool() const { + return width > 0 && height > 0; + } + + uint32_t width; + uint32_t height; +}; + +constexpr inline bool operator==(const Size& a, const Size& b) { + return a.width == b.width && a.height == b.height; +} + +constexpr inline bool operator!=(const Size& a, const Size& b) { + return !(a == b); +} + +} // namespace mbgl |