If I have a class Vector which is aligned to 16 bytes. Is it safe to have another struct containing Vector?
struct alignas(16) Vector {
//...
//overloaded operators that ensure alignment
void* operator new(size_t size){ return _aligned_malloc(size, 16); }
void operator delete(void* ptr) { if (ptr) _aligned_free(ptr); }
void* operator new[](size_t size) { return _aligned_malloc(size, 16); }
void operator delete[](void* ptr) { if (ptr) _aligned_free(ptr); }
};
struct someStruct {
Vector vector;
//some other data
};
Is the Vectorin someStructproperly aligned? What if I create someStructwith the newoperator?