The spica renderer
point2d.h
1 #ifdef _MSC_VER
2 #pragma once
3 #endif
4 
5 #ifndef _SPICA_POINT2D_H_
6 #define _SPICA_POINT2D_H_
7 
8 #include <string>
9 
10 namespace spica {
11 
12 template <class T>
13 class Point2_ {
14 public:
15  Point2_();
16  Point2_(T x, T y);
17  Point2_(const Point2_<T>& p);
18 
19  Point2_<T>& operator=(const Point2_<T>& p);
20  Point2_<T> operator-() const;
21  Point2_<T>& operator+=(const Point2_<T>& p);
22  Point2_<T>& operator-=(const Point2_<T>& p);
23  Point2_<T>& operator*=(T s);
24  T operator[](int i) const;
25 
26  inline T x() const { return x_; }
27  inline T y() const { return y_; }
28 
29  std::string toString() const;
30 
31 private:
32  T x_, y_;
33 
34  static_assert(std::is_arithmetic<T>::value,
35  "Template type must be arithmetic!!");
36 
37 }; // class Point2_
38 
39 using Point2i = Point2_<int>;
40 using Point2f = Point2_<float>;
41 using Point2d = Point2_<double>;
42 
43 } // namespace spica
44 
45 template <class T>
46 std::ostream& operator<<(std::ostream& os, const spica::Point2_<T>& p);
47 
48 template <class T>
49 spica::Point2_<T> operator+(const spica::Point2_<T>& p1, const spica::Point2_<T>& p2);
50 
51 template <class T>
52 spica::Point2_<T> operator-(const spica::Point2_<T>& p1, const spica::Point2_<T>& p2);
53 
54 template <class T>
55 spica::Point2_<T> operator*(const spica::Point2_<T>& p, T s);
56 
57 template <class T>
58 spica::Point2_<T> operator*(T s, const spica::Point2_<T>& p);
59 
60 // Include implementation
61 #include "point2d_detail.h"
62 
63 #endif // _SPICA_POINT2D_H_
Definition: core.hpp:62