More templated type argument inference

bearophile bearophileHUGS at lycos.com
Thu Dec 6 05:04:04 PST 2012


Currently this code is not supported:

void foo(T)(T x, T function(T) f) {}
void main() {
     foo(1, (int a) => a * a); // OK
     foo(1, a => a * a);       // Error
}


With the latest alpha compiler it gives:

test.d(4): Error: template test.foo does not match any function 
template declaration. Candidates are:
test.d(1):        test.foo(T)(T x, T function(T) f)
test.d(4): Error: template test.foo(T)(T x, T function(T) f) 
cannot deduce template function from argument types !()(int,void)


Do you think it's a good idea to allow it?

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list