Overloading funtion templates.
    Balagopal Komarath via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Wed Jun 28 04:49:57 PDT 2017
    
    
  
Shouldn't the compiler be able to resolve foo!g(3) to the first 
template foo?
import std.stdio;
import std.algorithm;
import std.range;
auto foo(F, T)(T x)
{
     return x.foo(F);
}
auto foo(F, T)(T x, F f)
{
     return f(x);
}
int g(int x) { return x; }
void main()
{
     foo(3, &g); // 2nd foo
     foo!g(3);   // error
}
I get the error message.
onlineapp.d(20): Error: template onlineapp.foo cannot deduce 
function from argument types !(g)(int), candidates are:
onlineapp.d(5):         onlineapp.foo(F, T)(T x)
onlineapp.d(10):        onlineapp.foo(F, T)(T x, F f)
    
    
More information about the Digitalmars-d-learn
mailing list