title: Friend operator in template struct raises redefinition error
body: <p>Consider this code:</p>
  
  <pre><code>template&lt;typename T,typename K&gt;
  struct A{
  
     friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp; out, K x) { 
        // Do some output 
        return out; 
     }
  
  };
  
  int main(){
     A&lt;int,int&gt; i;
     A&lt;double,int&gt; j;
  }
  </code></pre>
  
  <p>It does not compile, because the two instantiations of A instantiate the <code>operator&lt;&lt;</code> two times with the same signature, so I receive this error:</p>
  
  <pre><code>test.cpp:26:25: error: redefinition of ‘std::ostream&amp; operator&lt;&lt;(std::ostream&amp;, int)’
      friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp; out, K x) { return out; }
                           ^
  test.cpp:26:25: error: ‘std::ostream&amp; operator&lt;&lt;(std::ostream&amp;, int)’ previously defined here
  </code></pre>
  
  <p>How to fix this? How can I have a friend operator in a template, when that operator <em>might</em> have the same signature for two different instantiations? How can I solve this without triggering a redefinition error?</p>