c++ - Why function fun is not qualified for ADL? -
i have simple namespace
, has 1 variable , 1 function. in main
try call function without namespace qualifier, , variable namespace qualifier.
namespace sam { int p = 10; void fun(int) { cout<<"fun gets called"; } } int main() { fun(sam::p);//why sam::fun not called? return 0; }
i not able call fun, why not qualified adl (argument-dependant name lookup)?
i getting following error in visual studio.
'fun': identifier not found
if use sam::fun
, works.
adl adopted type, not variable, e.g.
namespace sam { struct p {}; void fun(p) { cout<<"fun gets called"; } } int main() { sam::p p; fun(p); return 0; }
in c++ programming language, argument-dependent lookup (adl), or argument-dependent name lookup, applies lookup of unqualified function name depending on types of arguments given function call.
reference: argument-dependent name lookup
Comments
Post a Comment