title: Specializing a template member function?
body: <p>I would like to have several different function definitions for a member function in a templated class. Something like this:</p>
  
  <pre><code>template &lt;typename T&gt;
  class MyClass
  {
    void Foo();
    T val;
  
    //other functionality and data
  };
  
    //handles all types
  template &lt;typename T&gt;
  void MyClass&lt;T&gt;::Foo()
  {
    return val;
  }
  
    //handles a special type in a different way
  template &lt;&gt;
  void MyClass&lt;float&gt;::Foo()
  {
    return val + 5.0f;
  }
  </code></pre>
  
  <p>I've tried implementing this as above and get a linker error for every special type I try to explicitly instantiate. The linker error mentions that the function has already been previously defined. Maybe I'm looking in the wrong places but I couldn't find any resources to help me figure out this problem  :(</p>
  
  <p>Q. Is this possible? If so, how do you do this and why does it work?</p>
  
  <p>Thanks!</p>