title: What is the fully qualified name of a friend function defined inside of a class?
body: <p>What is the fully qualified name of a friend function defined inside of a class?</p>
  
  <p>I recently saw an example analogous to the following. What is the fully qualified name of <code>val()</code> below?</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  namespace foo {
      class A {
          int x;
      public:
          A(int x = 0) : x(x) { }
  
          friend int val(const A &amp;a) { return a.x; }
      };
  }
  
  int main() {
      foo::A a(42);
  
      // val() found using ADL:
      std::cout &lt;&lt; val(a) &lt;&lt; std::endl;
  
      // foo::val(a); // error: 'val' is not a member of 'foo'
      // foo::A::val(a); // error: 'val' is not a member of 'foo::A'
  
      return 0;   
  }
  </code></pre>
  
  <p>Is argument-dependent lookup the only way <code>val()</code> can be found?</p>
  
  <p>Admittedly, this does not stem from a practical problem. I am simply looking to gain a better understanding.</p>