Function template literals - or "just" parameter type inference?

Kenji Hara k.hara.pg at gmail.com
Wed Nov 20 00:23:37 PST 2013


2013/11/20 Jakob Ovrum <jakobovrum at gmail.com>

>
>  I was not sure that the fun!int is legitimate usage.
>>
>
> I also ask this question. I think it may prove useful, and code in the
> wild might be relying on it.


One of the known issue is, that the specified type parameters may not match
exactly to the function parameters position.

You can make a partially specialized lambda like follows.

X!((int a, b) => a + b)

Then, inside X(alias fun), fun!long means instantiate (int a, long b){
return a + b; }.
And of course, fun!(int, int) will be invalid.

So, specifying type parameter for the template lambda will make the
template code unreliable.

I think it is not good feature in general.

Kenji Hara
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20131120/ba2a1c16/attachment.html>


More information about the Digitalmars-d mailing list