title: How to avoid repeated typing of template specializations in library for many types / functions
body: <p>I have various templated functions in a library cpp file which look in general like this:</p>
  
  <pre><code>template &lt;class TT&gt; TT im::BlockMultiplyAdd(const MtxView&lt;TT&gt; &amp;src1, const MtxView&lt;TT&gt; &amp;src2)
  {
  ...
  }
  </code></pre>
  
  <p>and have instantiations also in the cpp file that look like this:</p>
  
  <pre><code>template float im::BlockMultiplyAdd(const MtxView&lt;float&gt; &amp;src1, const MtxView&lt;float&gt; &amp;src2);
  template double im::BlockMultiplyAdd(const MtxView&lt;double&gt; &amp;src1, const MtxView&lt;double&gt; &amp;src2);
  template std::complex&lt;float&gt; im::BlockMultiplyAdd(const MtxView&lt;std::complex&lt;float&gt;&gt; &amp;src1, const MtxView&lt;std::complex&lt;float&gt;&gt; &amp;src2);
  template std::complex&lt;double&gt; im::BlockMultiplyAdd(const MtxView&lt;std::complex&lt;double&gt;&gt; &amp;src1, const MtxView&lt;std::complex&lt;double&gt;&gt; &amp;src2);
  </code></pre>
  
  <p>I also have declarations in the header file.</p>
  
  <p>Now I have many functions like this and I'm sick of typing the same specializations / declarations for the same set of four types over and over. Not all the functions have the same arguments, but they all have the same set of four types that they are built for.</p>
  
  <p>Is there any way that I can make a preprocessor macro or use template syntax or arrange my code more efficiently so that I can reduce typing (and make it less prone to mistakes)?</p>
  
  <p>Should I just be putting all the code in the header file for the templates? What are the pro/cons here for a static library?</p>