I'm confused by some rules in the standard. I'll cite them here:
[basic.lookup.argdep]:
Let X be the lookup set produced by unqualified lookup and let Y be the lookup set produced by argument dependent lookup (defined as follows).
So the sentence above means that the set X is created by unqualified lookup. Then we look at the rules of unqualified lookup:
[basic.lookup.unqual]:
In all the cases listed in [basic.lookup.unqual], the scopes are searched for a declaration in the order listed in each of the respective categories; name lookup ends as soon as a declaration is found for the name.
The emphasized part "name lookup ends as soon as a declaration is found for the name" means that once a name is found, the lookup stops.
So my question is:
void func(int){}
void func(double){}
int main(){
func(0);
}
Consider the above code. The name of fun
is used in an unqualified way. So the unqualified lookup rules are performed. Hence, once either func(double)
or func(int)
is found, the lookup is stopped. So, why can func
be overloaded, i.e. the set of candidate function contains both func(int)
and func(double)
? Doesn't it contradict the unqualified lookup rules? If I miss something, please correct me.