I am trying to use alignas
for pointers that are class members, and frankly I am not sure where I supposed to put it.
For instance:
class A
{
private:
int n;
alignas(64) double* ptr;
public:
A(const int num) : n(num), ptr(new double[num])
{}
};
which I hoped would ensure the data for ptr was aligned on a 64-byte block. Using the Intel compiler, it doesn't.
Can anyone point me in the right direction please?
A
). Or were you hoping that the dataptr
is pointing to would be over-aligned? That would require violation of causality. – Fetlocknew
possibly know that the pointer it produces would eventually be assigned to a variable declared withalignas
? That's what I mean by causality violation - you expect the implementation to be able to predict the future. – Fetlock