In C draft ISO(N4901/2021) 6.5.4 (Argument-dependent name lookup) we have:
When the postfix-expression in a function call (7.6.1.3) is an unqualified-id, and unqualified lookup (6.5.3) for the name in the unqualified-id does not find any (1.1) — declaration of a class member, or (1.2) — function declaration inhabiting a block scope, or (1.3) — declaration not of a function or function template
I can't figure out a example of an unqualified-id that contains a unqualified name(with the two being different). Draft gives the following example, but i couldn't say what is what in the (f)(s)
:
namespace N {
struct S { };
void f(S);
}
void g() {
N::S s;
f(s); // OK: calls N::f
(f)(s); // error: N::f not considered; parentheses prevent argument-dependent lookup
}
CodePudding user response:
unqualified-id that contains a unqualified name
The two are synonyms. The former is the correct term.
couldn't say what is what in the
(f)(s)
By the postfix-expression in this context they mean the thing being called. Consider:
[expr.call]/1
A function call is a postfix expression followed by parentheses containing ...
So, in (f)(s)
the postfix-expression is (f)
. It's clearly not an unqualified-id, so ADL doesn't apply.
CodePudding user response:
I can't figure out a example of an unqualified-id that contains a unqualified name(with the two being different).
The wording doesn't say «unqualified name». And seem to miss the word «component» before «name». Here is an example:
namespace N
{
struct S { };
template<typename T>
T f(S);
}
void g()
{
N::S s;
f<int>(s); // OK: calls N::f
}
unqualified-id here is f<int>
(which is template-id) and the lookup is performed for its component name f
.
A component name of an unqualified-id U is
— U if it is a name or
— the component name of the template-id or type-name of U, if any.
The component name of a simple-template-id, template-id, or template-name is the first name in it.
The paragraphs use the term «name» which is defined in [basic.pre]/4:
A name is an identifier ([lex.name]), operator-function-id ([over.oper]), literal-operator-id ([over.literal]), or conversion-function-id ([class.conv.fct]).