summaryrefslogtreecommitdiff
path: root/include/mbgl/util/size.hpp
blob: 79679a92fbf8ec6f738eeaa9a16699e7ab5e769a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#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 uint32_t area() const {
        return width * 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