| 42 | |
| 43 | template <uint32_t N, typename T> |
| 44 | class vec : public basisu::rel_ops<vec<N, T> > |
| 45 | { |
| 46 | public: |
| 47 | typedef T scalar_type; |
| 48 | enum |
| 49 | { |
| 50 | num_elements = N |
| 51 | }; |
| 52 | |
| 53 | inline vec() |
| 54 | { |
| 55 | } |
| 56 | |
| 57 | inline vec(basisu::eClear) |
| 58 | { |
| 59 | clear(); |
| 60 | } |
| 61 | |
| 62 | inline vec(const vec& other) |
| 63 | { |
| 64 | for (uint32_t i = 0; i < N; i++) |
| 65 | m_s[i] = other.m_s[i]; |
| 66 | } |
| 67 | |
| 68 | template <uint32_t O, typename U> |
| 69 | inline vec(const vec<O, U>& other) |
| 70 | { |
| 71 | set(other); |
| 72 | } |
| 73 | |
| 74 | template <uint32_t O, typename U> |
| 75 | inline vec(const vec<O, U>& other, T w) |
| 76 | { |
| 77 | *this = other; |
| 78 | m_s[N - 1] = w; |
| 79 | } |
| 80 | |
| 81 | template <typename... Args> |
| 82 | inline explicit vec(Args... args) |
| 83 | { |
| 84 | // static_assert(sizeof...(args) <= N); |
| 85 | set(args...); |
| 86 | } |
| 87 | |
| 88 | inline void clear() |
| 89 | { |
| 90 | if (N > 4) |
| 91 | memset(m_s, 0, sizeof(m_s)); |
| 92 | else |
| 93 | { |
| 94 | for (uint32_t i = 0; i < N; i++) |
| 95 | m_s[i] = 0; |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | template <uint32_t ON, typename OT> |
| 100 | inline vec& set(const vec<ON, OT>& other) |
| 101 | { |