File: point.hpp

package info (click to toggle)
mapbox-geometry 2.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 304 kB
  • sloc: cpp: 1,563; sh: 150; makefile: 37
file content (42 lines) | stat: -rw-r--r-- 678 bytes parent folder | download | duplicates (6)
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
37
38
39
40
41
42
#pragma once

namespace mapbox {
namespace geometry {

template <typename T>
struct point
{
    using coordinate_type = T;

    constexpr point()
        : x(), y()
    {
    }
    constexpr point(T x_, T y_)
        : x(x_), y(y_)
    {
    }

    T x;
    T y;
};

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"

template <typename T>
constexpr bool operator==(point<T> const& lhs, point<T> const& rhs)
{
    return lhs.x == rhs.x && lhs.y == rhs.y;
}

#pragma GCC diagnostic pop

template <typename T>
constexpr bool operator!=(point<T> const& lhs, point<T> const& rhs)
{
    return !(lhs == rhs);
}

} // namespace geometry
} // namespace mapbox