
3 Dec
2006
3 Dec
'06
12:15 p.m.
Daniel Wesslén wrote:
Not all swizzlings are named, but if the one you happen to want is not provided then it is easy to create: <snip example>
Apologies - the required header isn't exactly obvious (matrix.h includes definitions of matrix and vector, but matrix.tpp is required for the operations.) This should do it: #include <math/matrix.tpp> using namespace math; int main() { const indexer<bits::index_swizzle<0,0,2,0> > xxzx; const indexer<bits::index_swizzle<3,2,1,0> > wzyx; vector<4> v1, v2(1,2,3,4); v1 = v2[xxzx]; // v1 = (1,1,3,1) // v1[xxzx] = v2; // error - v1[xxzx] is not a lvalue due to aliasing v1[wzyx] = v2; // v1 = (4,3,2,1) } -- Daniel Wesslén