title: How to define template function in source file
body: <p>How can I declare template function in header file and define in source file?</p>
  
  <pre><code>// foo.h
  template&lt;typename T&gt;
  bool foo();
  
  // foo.cpp
  template&lt;typename T&gt;
  bool foo()
  {
      return false;
  }
  
  // main.cpp
  bool bar = foo&lt;int&gt;();
  </code></pre>
  
  <p>I've got this so far. It compiles, but fails at linker: <em>"undefined reference to `bool foo&lt;int&gt;()`"</em></p>