summaryrefslogtreecommitdiff
path: root/include/mbgl/util/size.hpp
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-10-26 15:22:31 -0700
committerIvo van Dongen <ivovandongen@users.noreply.github.com>2016-11-11 18:00:15 +0100
commitbf56187fb79f59930552c3ae34eaae78389536ca (patch)
treebde88c7aae11053c3263b050c0f9f79cbe36acb4 /include/mbgl/util/size.hpp
parent3e75feda52198952068ca45e290f8a691ba90b9f (diff)
downloadqtlocation-mapboxgl-bf56187fb79f59930552c3ae34eaae78389536ca.tar.gz
[core] change std::array<uint16_t, 2> to mbgl::Size
Diffstat (limited to 'include/mbgl/util/size.hpp')
-rw-r--r--include/mbgl/util/size.hpp32
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..c0e2fd8180
--- /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 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