This is in the namespace containing the class.
However, if it is declared only in a class, then it is available only for a search dependent on the argument. So this will work with the argument type A finding f in the surrounding namespace:
class A { friend void f(A) {} }; int main() { f(A());
This is often used for overloaded statements that can only be found by ADLs.
Your version will work if you have declared, but not redefined, a function in the namespace area.
void f();
source share