On Thu, 19 Jul 2007 14:45:31 -0300, Rodolfo Schulz de Lima wrote
> &print is not a call expression the same way &print<5> isn't, but
> the latter is resolved correctly.
It's because you have specified it explicitly.
> 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()'.
The function template `std::make_pair<>()' is an example.
You can directly call it without <>.
Since &print is not a call expression, C++ compilers cannot determine it by
function arguments.
This problem can be also reduced to this one:
==========
void foo() { }
void foo(int) { }
int main()
{
&foo;
}
==========
It's the same problem.
The instantiations of a function template can co-exist with non-template
function, and they're treated as overloaded functions in C++ compilers.
In fact, the overload resolution mechanism is never performed here since
it's not a call expression.
You can only speicify it explicitly.