If I have a function defined as friend inside a class. What is the namespace of that function?
namespace A{namespace B{
struct S{
friend void f(S const&){};
};
}}
int main(){
A::B::S s{};
f(s); // ok
::f(s); // not ok, no f in global namespace
A::B::f(s); // no f in A::B
A::B::S::f(s); // not ok, no f in A::B::S
}
Does it even have a namespace? Does it make sense for it to have a namespace?
What if I want to disambiguate a call in the commonly used idiom?
using std::swap;
swap(a, b);
Am I forced to define it outside the class and declare it a friend?