C++ STL data structure alignment, algorithm vectorization
alignment, c++, stl, vectorization
Solution
With STL containers, you can provide your own allocator via an optional template parameter. I wouldn't recommend writing an entire allocator from scratch, but you could write one that's just a wrapper around `new` and `delete` but ensures that the returned memory meets your alignment requirement. (E.g., if you need `n` bytes with 16-byte alignment, you use `new` to allocate `n + 15` bytes and return a pointer to the first 16-byte aligned address in that block.)
But it might be enough just to add the alignment attribute to the element type. That's outside the scope of the standard, so you'd have to check your compiler documentation and try it.
Problem
Is there a way to enforce STL container alignment to specific byte, using attribute((aligned))perhaps? the target compilers are not Microsoft Visual C++. What libraries, if any, provide specialized templates of STL algorithms which have specific explicit vectorization, e.g. SSE. My compilers of interest are g++, Intel, and IBM XL.