Ling-hua Tseng escreveu:
Since the sub-expression `&print' is not a call expression,
the overload resolution mechanism will not select the non-template version
first.
&print is not a call expression the same way &print<5> isn't, but the
latter is resolved correctly.
And the function templates can be instantiated without <>,
so the C++ compiler is confused.
I cannot see how a template function can be instantiated without <>,
since its instantiation needs the template parameters. That's why I
think that the compiler shouldn't even consider this situation in
overload resolution. With this said, in your exemple the only overload
for '&foo' should be 'void foo()'.
==========
void foo() { }
template<class T> void foo() { }
int main()
{
&foo;
}
==========
It can help you to understand what's happend.
Yes, thank you, your example is much more concise.
Thanks,
Rodolfo Lima.