I am trying the below simple thing to exercise the behavior of ADL
namespace test{
struct S{ public: s():a(10){} int a;};
template<typename T>
void fun(S o){
T a{};
std::cout<<(a+o.a)<<"\n";
}
}
int main(){
test::S A;
fun<int>(A);
}
error1: expected primary-expression before ‘int’
fun<(int)>(A);
error2:'fun’ was not declared in this scope
fun<int>(A);
I am not sure about the first error(has it anything to deal with C++ vexing parse?) and for the second error since I've passed the argument of type S
I believe that the ADL will consider S
and its associated namespace test
but not sure why I am getting 'fun’ was not declared
error.