Cześć,
czytam o ADL na cppreference:
Otherwise, for every argument in a function call expression its type is examined to determine the associated set of namespaces and classes that it will add to the lookup.
- For arguments of fundamental type, the associated set of namespaces and classes is empty
- For arguments of class type (including union), the set consists of
a) The class itself
b) All of its direct and indirect base classes
c) If the class is a member of another class, the class of which it is a member
d) The innermost enclosing namespaces in the classes added to the set
Sprawdzam różne opcje i tak. Poniższy kod działa, funkcja f jest sobie w jakiejś przestrzeni nazw blisko A i bez problemu została znaleziona.
class A
{
friend void f(A) { }
};
int main() {
A a;
f(a);
}
Gdy jednak zamienię friend na static to funkcja f już nie może być znaleziona:
class A
{
static void f(A) { }
};
int main() {
A a;
f(a);
}
Dlaczego tak się dzieje? Funkcja powinna chyba być znaleziona (obstawiam punkt a).