More templated type argument inference

Timon Gehr timon.gehr at gmx.ch
Fri Dec 7 12:24:55 PST 2012


On 12/06/2012 02:04 PM, 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

I consider it necessary.


More information about the Digitalmars-d-learn mailing list