title: Force template parameter to be a structure
body: <p>I'm trying to do a base template class which parameter <strong>T</strong> must be a structure.</p>
  
  <p>When I use a variable declared as being of type <strong>T</strong> (both in the template class as in a class that extends it defining <strong>T</strong>) GCC fails to compile it:</p>
  
  <blockquote>
    <p>GCC error: invalid use of incomplete
    type ‘struct x'</p>
  </blockquote>
  
  <p>Despite it working on VC I understand that it doesn't work because it shouldn't because the compiler isn't aware per the standard of the types that <strong>T</strong> represent.</p>
  
  <p>Is there a way of making explicit that the type must be a structure?</p>
  
  <p>What I'm doing in the code that works in VC is:</p>
  
  <p>In the base class:</p>
  
  <pre><code>T* x
  new T
  sizeof(T)
  </code></pre>
  
  <p>In those that extend it:</p>
  
  <pre><code>x-&gt;member
  </code></pre>
  
  <p>Edit: I tried to take the relevant code. Here it is:</p>
  
  <pre><code>struct SomeStructureType
  {
      int memberA;
      int memberB;
  }
  
  template &lt;typename T&gt; class Base
  {
  
      protected:
  
          T* s;
  
          void addMember(string name,void* offset);
  
          Base()
          {
              s = new T;
          }
  
  };
  
  class Extender : public Base&lt;SomeStructureType&gt;
  {
      public:
  
          Extender()
          {
              addMember("memberA",&amp;s-&gt;memberA);
          }
  }
  </code></pre>