Boost logo

Boost :

From: Daniel Wesslén (daniel_at_[hidden])
Date: 2006-12-03 07:15:28

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

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

Boost list run by bdawes at, gregod at, cpdaniel at, john at