title: how to specialize templated member functions of non-templated classes?
body: <p>suppose I have a file alpha.h:</p>
  
  <pre><code>class Alpha {
  public:
      template&lt;typename T&gt; void foo();
  };
  
  template&lt;&gt; void Alpha::foo&lt;int&gt;() {}
  template&lt;&gt; void Alpha::foo&lt;float&gt;() {}
  </code></pre>
  
  <p>If I include alpha.h in more than one cpp file and compile with GCC 4.4, it complains there are multiple definitions of <code>foo&lt;int&gt;</code> and <code>foo&lt;float&gt;</code> across multiple object files.  Makes sense to me, so I change the last two lines to:</p>
  
  <pre><code>template&lt;&gt; extern void Alpha::foo&lt;int&gt;() {}
  template&lt;&gt; extern void Alpha::foo&lt;float&gt;() {}
  </code></pre>
  
  <p>But then GCC says:</p>
  
  <blockquote>
    <p>explicit template specialization
    cannot have a storage class</p>
  </blockquote>
  
  <p>ok... so how am I supposed to do this correctly?  I'm worried that C++ doesn't allow what I'm trying to do in the first place, in which case is there a good idiom that will accomplish the same thing?</p>