Jet  v1.3.3
point.h
Go to the documentation of this file.
1 // Copyright (c) 2018 Doyub Kim
2 //
3 // I am making my contributions/submissions to this project solely in my
4 // personal capacity and am not conveying any rights to any intellectual
5 // property of any third parties.
6 
7 #ifndef INCLUDE_JET_POINT_H_
8 #define INCLUDE_JET_POINT_H_
9 
10 #include <jet/macros.h>
11 #include <array>
12 #include <type_traits>
13 
14 namespace jet {
15 
22 template <typename T, size_t N>
23 class Point final {
24  public:
25  static_assert(
26  N > 0, "Size of static-sized point should be greater than zero.");
27  static_assert(
28  std::is_arithmetic<T>::value,
29  "Point only can be instantiated with arithmetic types");
30 
32  Point();
33 
35  template <typename... Params>
36  explicit Point(Params... params);
37 
39  template <typename U>
40  explicit Point(const std::initializer_list<U>& lst);
41 
43  Point(const Point& other);
44 
46  template <typename U>
47  void set(const std::initializer_list<U>& lst);
48 
50  void set(const Point& other);
51 
53  template <typename U>
54  Point& operator=(const std::initializer_list<U>& lst);
55 
57  Point& operator=(const Point& other);
58 
60  const T& operator[](size_t i) const;
61 
63  T& operator[](size_t);
64 
65  private:
66  std::array<T, N> _elements;
67 
68  template <typename... Params>
69  void setAt(size_t i, T v, Params... params);
70 
71  void setAt(size_t i, T v);
72 };
73 
74 } // namespace jet
75 
76 #include "detail/point-inl.h"
77 
78 #endif // INCLUDE_JET_POINT_H_
79 
jet::Point::set
void set(const Point &other)
Set point instance with other point.
jet::Point::operator=
Point & operator=(const Point &other)
Set point instance with other point.
macros.h
jet::Point::Point
Point(const Point &other)
Copy constructor.
jet
Definition: advection_solver2.h:18
jet::Point::operator[]
const T & operator[](size_t i) const
Returns the const reference to the i -th element.
jet::Point::Point
Point()
Constructs a point with zeros.
jet::Point::Point
Point(Params... params)
Constructs point instance with parameters.
jet::Point::set
void set(const std::initializer_list< U > &lst)
Set point instance with initializer list.
jet::Point
Generic N-D point class.
Definition: point.h:23
jet::Point::operator=
Point & operator=(const std::initializer_list< U > &lst)
Set point instance with initializer list.
jet::Point::operator[]
T & operator[](size_t)
Returns the reference to the i -th element.
jet::Point::Point
Point(const std::initializer_list< U > &lst)
Constructs point instance with initiazer list.