Let us define f
, as a friend function of S
, inside the declaration of S
:
struct S
{
friend void f() {}
};
I cannot find a way to call f
.
Is it true, then, that such an inline friend function can only be called with argument-dependant lookup?
struct S
{
friend void f() {}
friend void g(S const&) {}
} const s;
int main()
{
// f(); // error: 'f' was not declared in this scope
// S::f(); // error: 'f' is not a member of 'S'
g(s);
// S::g(s); // error: 'g' is not a member of 'S'
}
Bonus: what if I want to get a function-pointer/std::function
/lambda to g
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…