The spica renderer
triplet.h
1 #ifdef _MSC_VER
2 #pragma once
3 #endif
4 
5 #ifndef _SPICA_TRIPLET_H_
6 #define _SPICA_TRIPLET_H_
7 
8 #include <array>
9 
10 #include "common.h"
11 
12 namespace spica {
13 
14  template <class T, class Enable = void>
15  class Triplet_;
16 
17  template <class T>
18  class Triplet_<T, typename std::enable_if<std::is_arithmetic<T>::value>::type> {
19  private:
20  std::array<T, 3> _data;
21 
22  public:
23  Triplet_()
24  : _data() {
25  }
26 
27  Triplet_(T i, T j, T k)
28  : _data() {
29  _data[0] = i;
30  _data[1] = j;
31  _data[2] = k;
32  }
33 
34  Triplet_(const Triplet_<T>& triplet)
35  : _data() {
36  this->operator=(triplet);
37  }
38 
39  ~Triplet_() {
40  }
41 
42  Triplet_& operator=(const Triplet_<T>& triplet) {
43  this->_data = triplet._data;
44  return *this;
45  }
46 
47  T operator[](int i) const {
48  Assertion(0 <= i && i <= 2, "access index out of bounds!");
49  return _data[i];
50  }
51  };
52 
53  using Triplet = Triplet_<int>;
54 
55 } // namespace spica
56 
57 #endif // _SPICA_TRIPLET_H_
Definition: triplet.h:15