title: How to make code generation depending on template arguments?
body: <p>can I prevent the generation of a function of a templated class if the template arguments does not meet a criteria (certain value or type)?
  Can this be achieved by using c++ code and no preprocessor directives?</p>
  
  <p>This kind of function should neither be available in the header nor in the body.
  This case may seem a little artificial but i did not find a solution yet.</p>
  
  <p>Example class (simplified - no constructor etc.):</p>
  
  <p><strong>MyClass.h</strong></p>
  
  <pre class="lang-cpp prettyprint-override"><code>template&lt;int Dimension, typename TPixelType = float&gt;
      class MyClass
  {
      void DoSomething();
      void DoAnotherThing(); // this function should only be available if Dimension &gt; 2
  }
  </code></pre>
  
  <p><strong>MyClass.cxx</strong></p>
  
  <pre class="lang-cpp prettyprint-override"><code>template&lt; int Dimension, typename TPixelType&gt; void MyClass::DoSomething()
  {...}
  
  // pseudocode: if Dimension &lt;= 2 do not compile next function
  template&lt; int Dimension, typename TPixelType&gt; void MyClass::DoAnotherThing() 
  {
      MethodNotToBeCompiled(); // The function I don't want to be executed
  }
  </code></pre>
  
  <p><strong>TestMyClass.cxx</strong></p>
  
  <pre class="lang-cpp prettyprint-override"><code>int main()
  {
      auto myclass0 = MyClass&lt;2&gt;();
      myclass0.DoSomething(); // OK
      myclass0.DoAnotherThing(); // (wanted) error - function not available
  
      auto myclass1 = MyClass&lt;3&gt;();
      myclass1.DoSomething(); // OK
      myclass1.DoAnotherThing(); // OK
  }
  </code></pre>
  
  <p><strong>Is this possible in C++XX? Or is there another approach than preprocessor directives?</strong></p>