-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoord.h
53 lines (43 loc) · 998 Bytes
/
coord.h
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
43
44
45
46
47
48
49
50
51
52
53
#ifndef COORD_H
#define COORD_H
#include <array>
template <typename T, const uint16_t DimensionV>
class Coordinate {
public:
explicit Coordinate(const std::array<T, DimensionV> &values)
: values(values)
{ }
private:
std::array<T, DimensionV> values;
};
template <typename T>
struct Coordinate <T, 1> {
Coordinate(const T &value)
: values({{value}})
{ }
explicit Coordinate(const std::array<T, 1> &values)
: values(values)
{ }
std::array<T, 1> values;
};
template <typename T>
struct Coordinate <T, 2> {
Coordinate(const T &val1, const T &val2)
: values({{val1, val2}})
{ }
explicit Coordinate(const std::array<T, 2> &values)
: values(values)
{ }
std::array<T, 2> values;
};
template <typename T>
struct Coordinate <T, 3> {
Coordinate(const T &val1, const T &val2, const T &val3)
: values({{val1, val2, val3}})
{ }
explicit Coordinate(const std::array<T, 3> &values)
: values(values)
{ }
std::array<T, 3> values;
};
#endif