title: Explicit specialization after instantiation
body: <p>I have the following code:</p>
  
  <pre><code>typedef vector&lt;int&gt; Vec;
  typedef vector&lt;Vec&gt; VecOfVec;
  
  template&lt;typename Vec&gt;
  Vec DoSomething(const Vec &amp;v);
  
  template&lt;&gt;
  VecOfVec DoSomething&lt;VecOfVec&gt;(const VecOfVec &amp;v)
  {
      VecOfVec r;
      for(auto i = v.begin(); i != v.end(); i++)
          r.push_back(DoSomething(*i));
      return r;
  }
  
  template&lt;&gt;
  Vec DoSomething&lt;Vec&gt;(const Vec &amp;v) // Error here
  {
      return v; // for the sake of the example
  }
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>explicit specialization of 'DoSomething&lt;vector&lt;int&gt; &gt;' after instantiation
  </code></pre>
  
  <p>at the marked line.<br>
  The compiler insists that it already instantiated <code>DoSomething&lt;vector&lt;int&gt; &gt;</code>, while it cannot, and a simple program can prove it:</p>
  
  <pre><code>typedef vector&lt;int&gt; Vec;
  typedef vector&lt;Vec&gt; VecOfVec;
  
  template&lt;typename Vec&gt;
  Vec DoSomething(const Vec &amp;v);
  
  template&lt;&gt;
  VecOfVec DoSomething&lt;VecOfVec&gt;(const VecOfVec &amp;v)
  {
      VecOfVec r;
      for(auto i = v.begin(); i != v.end(); i++)
          r.push_back(DoSomething(*i));
      return r;
  }
  </code></pre>
  
  <p>Results in unresolved external.<br>
  Why is the compiler saying it already instantiated it when it cannot and even does not? and why doesn't the compiler treat it as unresolved symbol, while the linker does?
  I know switching the method order solves it, but I want to know why is the compiler doing it.</p>