title: Hidden friends: declarations and definitions
body: <p>In his recent <a href="https://www.justsoftwaresolutions.co.uk/cplusplus/hidden-friends.html" rel="noreferrer">blog post</a> Anthony Williams talks about hidden friends. The main idea, if I understood it correctly, is that functions declared as friends cannot be found by ADL in certain situations. Simple example:</p>
  
  <pre><code>namespace N {
      struct A {
          friend void foo(A) { }
      };
  
      struct B {
          operator A();
      };
  
      // (*)
      void bar(A) { }
  }
  
  void func() {
      N::A a;
      bar(a);   // OK, bar is found via ADL
      foo(a);   // OK, foo is found via ADL
  
      N::B b;
      bar(b);   // OK, bar is found via ADL
      foo(b);   // NOT OK, foo cannot be found
  }
  </code></pre>
  
  <p>In all examples in the blog post, the friend functions are defined inside classes. Is it possible to declare a friend function and then define it later at the point <code>(*)</code>, so that it <strong>remains</strong> hidden? It looks like hidden friends can only be defined in the class scope (or in another compilation unit).</p>