I am writing a software rasteriser using MSVC++ Express 2010 for windows. I am using SSE and need aligned data structures. I have a number of separate vector structs for different fundamental data types (float, int etc.) that I want to roll into one templated struct for convenience. The _declspec(align(16)) tag which has served well for aligning structs doesn't appear to work for templates. What are my options? This is what I would like to achieve:
/* _declspec(align(16)) */
template< typename T > struct baseVector
{
T v[ 4 ];
};
typedef baseVector< float > vector, vertex, point; // etc
I have tried specialising the template and using the _declspec(align()) but the compiler complains. I have tried using #pragma pack() as well but I don't think that has any aligning effect when these structs are members of higher level structs.