treating memory returned by operator new(sizeof(T) * N) as an array

The issue of pointer arithmetic on allocated memory, as in your example: T* storage = static_cast<T*>(operator new(sizeof(T)*size)); // … T* p = storage + i; // precondition: 0 <= i < size new (p) T(element); being technically undefined behaviour has been known for a long time. It implies that std::vector can’t be implemented with well-defined … Read more

Where can I use alignas() in C++11?

I think you just placed the alignas in the wrong position. If you move it directly after the identifier, both GCC and Clang are happy and apply the alignment: typedef float aligned_block alignas(16) [4]; typedef float aligned_block [4] alignas(16); this is also true if you use using, where the difference also becomes more apparent. Here … Read more