I want the storage of my vectors to be aligned (say, to the border of 16 bytes), so I have this allocator as a wrapper on memalign() , I wonder if it is right to choose the allocated memory used with STL vectors.
template <class T , int Alignment=16> class AlignedAllocator { public: ... pointer allocate (size_type size, const_pointer *hint = 0) { return (pointer) memalign(Alignment, size*sizeof (T)); }; void deallocate (pointer p, size_type size) { free(p); }; ... }
If not, are there implementations available for aligned dispensers that work with STL containers?
PS: I am compiling with gcc.
source share