Hello
I want to align my member variables based on a class template type but I'm not sure if it is actually possible.
The following is a (very) simple example of what I'd like to do
template<int Align>
class MyClass
{
private:
struct MyStruct
{
// Some stuff
} __declspec(align(Align));
__declspec(align(Align)) int myAlignedVariable;
};
So what I'd like is for Align to be a per-instance variable, and only through that is the align value of the class contents decided.
Unfortunately I always get the following error
error C2975: 'test::MyClass' : invalid template argument for 'Align', expected compile-time constant expression
So, is this actually possible or can the alignment only be possible using a fixed compile time constant? If not, can anyone think of a way around this?
Thanks :)