title: C++ Class partial specialization on non-type template parameter
body: <p>I'm not sure I'm getting the terminology correct, but I think I have a class template with both a type and non-type template parameter and I want to partially specialize on the non-type parameter alone:</p>
  
  <pre><code>template&lt;class T, int I&gt; struct A
  {
      void f();
  };
  
  template&lt;class T&gt; void A&lt;T, 1&gt;::f() {}
  
  int main()
  {
      A&lt;int, 1&gt; a1;
      a1.f();
  }
  </code></pre>
  
  <p>Using Visual C++ I get <code>error C3860: template argument list following class template name must list parameters in the order used in template parameter list</code> and <code>error C2976: 'A&lt;T,I&gt;': too few template arguments</code>.</p>
  
  <p>However if I remove the type parameter then it seems I can specialize on the non-type parameter:</p>
  
  <pre><code>template&lt;int I&gt; struct B
  {
      void g();
  };
  
  void B&lt;1&gt;::g() {}
  
  int main()
  {
      B&lt;1&gt; b1;
      b1.g();
  }
  </code></pre>
  
  <p>So is what I want impossible, or I'm just not doing it the right way? If it's not possible, is there an alternative?</p>