On Thursday, 6 December 2012 at 13:04:05 UTC, bearophile wrote:
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

The second is template lambda and templates have void type. What you suggest here?

Reply via email to