More templated type argument inference
Maxim Fomin
maxim at maxim-fomin.ru
Thu Dec 6 05:29:23 PST 2012
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?
More information about the Digitalmars-d-learn
mailing list