title: Aligning Member Variables By Template Type
body: <p>I want to align my member variables based on a class template type but I'm not sure if it is actually possible.</p>
  
  <p>The following is a (very) simple example of what I'd like to do</p>
  
  <pre><code>template&lt;int Align&gt;
  class MyClass
  {
  private:
    struct MyStruct
    {
      // Some stuff
    } __declspec(align(Align));
  
    __declspec(align(Align)) int myAlignedVariable;
  };
  </code></pre>
  
  <p>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.</p>
  
  <p>Unfortunately I always get the following error</p>
  
  <pre><code>error C2975: 'test::MyClass' : invalid template argument for 'Align', expected compile-time constant expression
  </code></pre>
  
  <p>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?</p>
  
  <p>Thanks :)</p>