title: Templated operator<< explicit instantiation and header
body: <p>Typically for my templated classes, I include declarations in a <code>.hpp</code> file and templated implementation code in a <code>.t.hpp</code> file. I explicitly instantiate the class in a <code>.cpp</code> file:</p>
  
  <pre><code>template class MyClass&lt; AnotherClass &gt;;
  </code></pre>
  
  <p>whose object code gets put in a library.</p>
  
  <p>The problem is that if I try to print the object with <code>operator&lt;&lt;</code>, which is declared in the <code>.hpp</code> file and defined in the <code>.t.hpp</code> file as:</p>
  
  <pre><code>template&lt;class T&gt;
  std::ostream&amp; operator&lt;&lt;( std::ostream&amp; os, const MyClass&lt;T&gt;&amp; c)
  {
      os  &lt;&lt; "Hello, I am being output.";
      return os;
  }
  </code></pre>
  
  <p>I get a linker error saying that the right symbol is undefined.</p>
  
  <p>I understand that this is because this templated function is not explicitly instantiated when the class is. Is there a way to get around this other than to include the <code>.t.hpp</code> file any time I want to use <code>operator&lt;&lt;</code> on the class, or to move the templated function code into the <code>.hpp</code> file? Can I explicitly instantiate the function code?</p>