@@ -94,44 +94,44 @@ template<size_t N_DST = N, enum align A_DST = align::adaptive>
9494operator vec<T,N_DST,A_DST>() { return *reinterpret_cast <vec<T,N_DST,A_DST>*>(this ); }
9595
9696constexpr inline T& x () { return (*this )[0 ]; }
97- constexpr inline T& y () { return (*this )[1 ]; }
98- constexpr inline T& z () { return (*this )[2 ]; }
99- constexpr inline T& w () { return (*this )[3 ]; }
97+ constexpr inline T& y () { static_assert (N >= 2 ); return (*this )[1 ]; }
98+ constexpr inline T& z () { static_assert (N >= 3 ); return (*this )[2 ]; }
99+ constexpr inline T& w () { static_assert (N >= 4 ); return (*this )[3 ]; }
100100
101101constexpr inline const T& x () const { return (*this )[0 ]; }
102- constexpr inline const T& y () const { return (*this )[1 ]; }
103- constexpr inline const T& z () const { return (*this )[2 ]; }
104- constexpr inline const T& w () const { return (*this )[3 ]; }
102+ constexpr inline const T& y () const { static_assert (N >= 2 ); return (*this )[1 ]; }
103+ constexpr inline const T& z () const { static_assert (N >= 3 ); return (*this )[2 ]; }
104+ constexpr inline const T& w () const { static_assert (N >= 4 ); return (*this )[3 ]; }
105105
106106constexpr inline T& p () { return (*this )[0 ]; }
107- constexpr inline T& h () { return (*this )[1 ]; }
108- constexpr inline T& b () { return (*this )[2 ]; }
107+ constexpr inline T& h () { static_assert (N >= 2 ); return (*this )[1 ]; }
108+ constexpr inline T& b () { static_assert (N >= 3 ); return (*this )[2 ]; }
109109
110110constexpr inline const T& p () const { return (*this )[0 ]; }
111- constexpr inline const T& h () const { return (*this )[1 ]; }
112- constexpr inline const T& b () const { return (*this )[2 ]; }
111+ constexpr inline const T& h () const { static_assert (N >= 2 ); return (*this )[1 ]; }
112+ constexpr inline const T& b () const { static_assert (N >= 3 ); return (*this )[2 ]; }
113113
114114constexpr inline T& u () { return (*this )[0 ]; }
115- constexpr inline T& v () { return (*this )[1 ]; }
116- constexpr inline T& u2 () { return (*this )[2 ]; }
117- constexpr inline T& v2 () { return (*this )[3 ]; }
118- constexpr inline T& s () { return (*this )[2 ]; }
119- constexpr inline T& t () { return (*this )[3 ]; }
115+ constexpr inline T& v () { static_assert (N >= 2 ); return (*this )[1 ]; }
116+ constexpr inline T& u2 () { static_assert (N >= 3 ); return (*this )[2 ]; }
117+ constexpr inline T& v2 () { static_assert (N >= 4 ); return (*this )[3 ]; }
118+ constexpr inline T& s () { static_assert (N >= 3 ); return (*this )[2 ]; }
119+ constexpr inline T& t () { static_assert (N >= 4 ); return (*this )[3 ]; }
120120constexpr inline const T& u () const { return (*this )[0 ]; }
121- constexpr inline const T& v () const { return (*this )[1 ]; }
122- constexpr inline const T& u2 () const { return (*this )[2 ]; }
123- constexpr inline const T& v2 () const { return (*this )[3 ]; }
124- constexpr inline const T& s () const { return (*this )[2 ]; }
125- constexpr inline const T& t () const { return (*this )[3 ]; }
121+ constexpr inline const T& v () const { static_assert (N >= 2 ); return (*this )[1 ]; }
122+ constexpr inline const T& u2 () const { static_assert (N >= 3 ); return (*this )[2 ]; }
123+ constexpr inline const T& v2 () const { static_assert (N >= 4 ); return (*this )[3 ]; }
124+ constexpr inline const T& s () const { static_assert (N >= 3 ); return (*this )[2 ]; }
125+ constexpr inline const T& t () const { static_assert (N >= 4 ); return (*this )[3 ]; }
126126
127127constexpr inline T& l () { return (*this )[0 ]; }
128128constexpr inline T& r () { return (*this )[0 ]; }
129- constexpr inline T& g () { return (*this )[1 ]; }
130- constexpr inline T& a () { return (*this )[3 ]; }
129+ constexpr inline T& g () { static_assert (N >= 2 ); return (*this )[1 ]; }
130+ constexpr inline T& a () { static_assert (N >= 4 ); return (*this )[3 ]; }
131131constexpr inline const T& l () const { return (*this )[0 ]; }
132132constexpr inline const T& r () const { return (*this )[0 ]; }
133- constexpr inline const T& g () const { return (*this )[1 ]; }
134- constexpr inline const T& a () const { return (*this )[3 ]; }
133+ constexpr inline const T& g () const { static_assert (N >= 2 ); return (*this )[1 ]; }
134+ constexpr inline const T& a () const { static_assert (N >= 4 ); return (*this )[3 ]; }
135135
136136constexpr static inline const vec<T,N,A> id (ssize_t i = -1 ) { vec<T,N> dst = {}; if (i == -1 ) dst.fill (1 ); else dst[i % N] = (T)1 ; return dst; }
137137constexpr static inline const vec<T,N,A> ne () { vec<T,N,A> dst = {}; return dst; }
0 commit comments