Boost LA

Swizzling Support

For vectors, besides simple element access, Boost LA supports arbitrary element swizzling for 2D, 3D and 4D vectors.

#include <boost/la/swizzle.hpp>

namespace
boost
    {
    namespace
    la
        {
        //2D view proxies:
        -unspecified-return-type- XX();
        -unspecified-return-type- XY();
        -unspecified-return-type- XZ();
        -unspecified-return-type- XW();
        -unspecified-return-type- X0();
        -unspecified-return-type- X1();
        -unspecified-return-type- YX();
        -unspecified-return-type- YY();
        -unspecified-return-type- YZ();
        -unspecified-return-type- YW();
        -unspecified-return-type- Y0();
        -unspecified-return-type- Y1();
        -unspecified-return-type- ZX();
        -unspecified-return-type- ZY();
        -unspecified-return-type- ZZ();
        -unspecified-return-type- ZW();
        -unspecified-return-type- Z0();
        -unspecified-return-type- Z1();
        -unspecified-return-type- WX();
        -unspecified-return-type- WY();
        -unspecified-return-type- WZ();
        -unspecified-return-type- WW();
        -unspecified-return-type- W0();
        -unspecified-return-type- W1();
        
        //3D view proxies:
        -unspecified-return-type- XXX();
        ...
        -unspecified-return-type- XXW();
        -unspecified-return-type- XX0();
        -unspecified-return-type- XX1();
        -unspecified-return-type- XYX();
        ...
        -unspecified-return-type- XY1();
        ...
        -unspecified-return-type- WW1();
        
        //4D view proxies:
        -unspecified-return-type- XXXX();
        ...
        -unspecified-return-type- XXXW();
        -unspecified-return-type- XXX0();
        -unspecified-return-type- XXX1();
        -unspecified-return-type- XXYX();
        ...
        -unspecified-return-type- XXY1();
        ...
        -unspecified-return-type- WWW1();
        }
    }

These functions can be used to create 2D, 3D, and 4D view proxies to any vector object.

The expression v|XX is equivalent to v|sw<_x_,_x_>, v|XY is equivalent to v|sw<_x_,_y_> and so on.

Similarly, v|XXX is equivalent to v|sw<_x_,_x_,_x_>, v|XXY is equivalent to v|sw<_x_,_x_,_y_>, and so on.

Finally, v|XXXX is equivalent to v|sw<_x_,_x_,_x_,_x_>, v|XXXY is equivalent to v|sw<_x_,_x_,_x_,_y_>, and so on.