title: Template partial specialization problems
body: <p>I am trying to write a size and type generic vector class for math programming. I am having problems with partial specialization.</p>
  
  <p>The problem occurs when I try to specialize a member method of my vector class for given size.</p>
  
  <p>I can provide a simple example:</p>
  
  <pre><code>template &lt;size_t Size, typename Type&gt;
  class TestVector
  {
  public:
      inline TestVector (){}
      TestVector cross (TestVector const&amp; other) const;
  };
  
  template &lt; typename Type &gt;
  inline TestVector&lt; 3, Type &gt; TestVector&lt; 3, Type &gt;::cross (TestVector&lt; 3, Type &gt; const&amp; other) const
  {
      return TestVector&lt; 3, Type &gt;();
  }
  
  void test ()
  {
      TestVector&lt; 3, double &gt; vec0;
      TestVector&lt; 3, double &gt; vec1;
      vec0.cross(vec1);
  }
  </code></pre>
  
  <p>When trying to compile this simple example I get a compilation error stating the 'cross' specialization does not match an existing declaration:</p>
  
  <pre><code>error C2244: 'TestVector&lt;Size,Type&gt;::cross' : unable to match function definition to an existing declaration
  see declaration of 'TestVector&lt;Size,Type&gt;::cross'
  definition
      'TestVector&lt;3,Type&gt; TestVector&lt;3,Type&gt;::cross(const TestVector&lt;3,Type&gt; &amp;) const'
      existing declarations
      'TestVector&lt;Size,Type&gt; TestVector&lt;Size,Type&gt;::cross(const TestVector&lt;Size,Type&gt; &amp;) const'
  </code></pre>
  
  <p>I have tried to declare cross as a template:</p>
  
  <pre><code>template &lt;size_t Size, typename Type&gt;
  class TestVector
  {
  public:
      inline TestVector (){}
  
      template &lt; class OtherVec &gt;
      TestVector cross (OtherVec const&amp; other) const;
  };
  
  template &lt; typename Type &gt;
  TestVector&lt; 3, Type &gt; TestVector&lt; 3, Type &gt;::cross&lt; TestVector&lt; 3, Type &gt; &gt; (TestVector&lt; 3, Type &gt; const&amp; other) const
  {
      return TestVector&lt; 3, Type &gt;();
  }
  </code></pre>
  
  <p>This version passes compilation but fails at link-time:</p>
  
  <pre><code> unresolved external symbol "public: class TestVector&lt;3,double&gt; __thiscall TestVector&lt;3,double&gt;::cross&lt;class TestVector&lt;3,double&gt; &gt;(class TestVector&lt;3,double&gt; const &amp;)const
  </code></pre>
  
  <p>What am I missing here ?
  Thanks,
  Florent</p>