title: Can Template Specializations go in my .cpp?
body: <p>Lets say that I have this:</p>
  
  <pre><code>struct foo {
      template &lt;typename T&gt;
      void bar(const T param) { cout &lt;&lt; param &lt;&lt; endl; }
  };
  </code></pre>
  
  <p>Now I want to add the specialization:</p>
  
  <pre><code>template &lt;&gt;
  void bar&lt;char&gt;(const char param) { cout &lt;&lt; static_cast&lt;int&gt;(param) &lt;&lt; endl; }
  </code></pre>
  
  <p>Can I just add the declaration to the header that <code>foo</code> is declared in and defince <code>bar&lt;char&gt;</code> in the implementation file <code>foo</code> is implemented in?</p>
  
  <hr>
  
  <p>The reason that I'm asking is that locally I'm seeing it work both ways. I think the difference is: Specialized template methods that I'm only using internally to the defining class can be defined in the implementation. Specialized template methods I'm using externally seem to need to be defined in the header. I haven't been able to find anything conclusive on this though so I thought I'd ask.</p>