alias with lambda syntax: alias fun2=a=>fun(a);

Timothee Cour via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jun 5 00:18:16 PDT 2014


ok I remembered we can use std.typetuple.Alias for that.


On Wed, Jun 4, 2014 at 11:58 PM, Timothee Cour <thelastmammoth at gmail.com>
wrote:

> Is there a way to do this?
>
> import std.algorithm;
>
> auto fun(T)(T a){return a;}
>
> template fun2(T){auto fun2(T a){return fun(a);}}//OK but heavy syntax and
> cannot be nested inside test()
>
> void main(){
>   //alias fun2=fun!int; //OK but needs to specify template params
>   //none of those work:
>   //alias fun2=a=>fun(a);
>   //alias fun2(T)=(T a)=>fun(a);
>   //alias fun2(T)=(T a){return fun(a);}
>   auto b=[1].map!fun2;
>   assert(b.equal([1]));
> }
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20140605/920ccfcc/attachment.html>


More information about the Digitalmars-d-learn mailing list