title: Friending template function from multiple classes
body: <p>I have this code:</p>
  
  <pre><code>template&lt;typename T&gt; T f() {
  // ...
  }
  
  class A {
      friend A f();
  };
  
  class B {
      friend B f();
  };
  </code></pre>
  
  <p>I get <code>ambiguating new declaration of ‘B f()’</code> error.</p>
  
  <p>However, if I change my code to following</p>
  
  <pre><code>template&lt;typename T&gt; void f(T arg) {
  // ...
  }
  
  class A {
      friend void f(A);
  };
  
  class B {
      friend void f(B);
  };
  </code></pre>
  
  <p>program compiles finely.</p>
  
  <p>Could someone help me figure out what is the problem?</p>