title: Which scope does an in-class-defined friend function belong to?
body: <pre><code>class A {
      friend void f() {}
  };
  
  // void f() {}  // compile error: redifinition of 'void f()'
  
  int main() {
      f();  // compile error: 'f' is not declared in this scope
  }
  </code></pre>
  
  <p>As you can see in the above example, if <code>f</code> is called in <code>A</code>'s enclosing namespace scope, the compiler just can't find <code>f</code>, which gives me the idea that <code>f</code> is not in this scope.  But when an out-of-calss definition of a function with the same signature is added, the compiler issues an error of function redefinition, which gives me the opposite idea that <code>f</code> is actually in this scope.</p>
  
  <p>So, I'm puzzled which scope an in-class-defined friend function belongs to.</p>