title: operator overloading for a class template specialization
body: <p>I got stuck with a confusing problem here and i couldnt find any solution so far:
  The linker complains about a multiple definition of an overloaded non-member operator==.
  Imagine the following situation:</p>
  
  <pre><code>template &lt;class T&gt;
  struct MyPtr
  {
    T* val;
    ...
  }
  
  template &lt;class T&gt; bool operator==(MyPtr&lt;T&gt; const &amp; lhs, MyPtr&lt;T&gt; const &amp; rhs)
  { return *lhs.val == *rhs.val; }
  template &lt;class T&gt; bool operator==(MyPtr&lt;T&gt; const &amp; lhs, T* const &amp; rhs)
  { return *lhs.val == *rhs;}
  </code></pre>
  
  <p>So far so good, everything works like a charme, but as i tried to specialize my class to react to a char* in specific way things get weird:</p>
  
  <pre><code>template &lt;&gt;
  struct MyPtr&lt;char&gt;
  {
    char* val;
    ...
  }
  
  //Now each of these functions result in a multiple definition error of the Linker, 
  //and i dont get why:
  //bool operator== (MyPtr&lt;char&gt; const&amp; lhs, MyPtr&lt;char&gt; const&amp; rhs)
  //{ return strcmp(lhs.val,rhs.val) == 0;}
  
  //template &lt;&gt; bool operator==&lt;char&gt; (MyPtr&lt;char&gt; const&amp; lhs, MyPtr&lt;char&gt; const&amp; rhs)
  //{ return strcmp(lhs.val,rhs.val) == 0;}
  </code></pre>
  
  <p>So what am i doing wrong here? The ordering in my code is as it is written here. Moving these function definitions above the Class specialization result in the error:</p>
  
  <pre><code>Error : specialization of 'MyPtr&lt;char&gt;' after instantiation
  Error : redefinition of 'class MyPtr&lt;char&gt;'
  </code></pre>
  
  <p>Please notice i have to use GCC 4.1.2 . I hope its not a compiler problem here... again...</p>