Point.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: Point.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: Generic N-D point class.
6 > Created Time: 2017/01/31
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_POINT_H
10 #define CUBBYFLOW_POINT_H
11 
12 #include <array>
13 #include <type_traits>
14 
15 namespace CubbyFlow
16 {
23  template <typename T, size_t N>
24  class Point final
25  {
26  public:
27  static_assert(N > 0, "Size of static-sized point should be greater than zero.");
28  static_assert(std::is_arithmetic<T>::value, "Point only can be instantiated with arithmetic types");
29 
31  Point();
32 
34  template <typename... Params>
35  explicit Point(Params... params);
36 
38  template <typename U>
39  explicit Point(const std::initializer_list<U>& list);
40 
42  Point(const Point& other);
43 
45  template <typename U>
46  void Set(const std::initializer_list<U>& list);
47 
49  void Set(const Point& other);
50 
52  template <typename U>
53  Point& operator=(const std::initializer_list<U>& list);
54 
56  Point& operator=(const Point& other);
57 
59  const T& operator[](size_t i) const;
60 
62  T& operator[](size_t);
63 
64  private:
65  std::array<T, N> m_elements;
66 
67  template <typename... Params>
68  void SetAt(size_t i, T v, Params... params);
69 
70  void SetAt(size_t i, T v);
71  };
72 }
73 
74 #include <Core/Point/Point-Impl.h>
75 
76 #endif
void Set(const std::initializer_list< U > &list)
Set point instance with initializer list.
Definition: Point-Impl.h:57
Generic N-D point class.
Definition: Point.h:24
Definition: pybind11Utils.h:24
Point & operator=(const std::initializer_list< U > &list)
Set point instance with initializer list.
const T & operator[](size_t i) const
Returns the const reference to the i -th element.
Definition: Point-Impl.h:91
Point()
Constructs a point with zeros.
Definition: Point-Impl.h:17