New Traits

John Maschmeyer jmaschme at gmail.com
Thu May 17 19:21:30 PDT 2012


On Thursday, 17 May 2012 at 21:39:03 UTC, Justin Whear wrote:
> An alias parameter to a template would actually be the ideal 
> use-case for
> what I have in mind. Essentially, it would work just like 
> map/reduce/
> filter (function passed by alias), but translate the lambda to 
> SQL/XPath/
> etc.

I just pushed an update that should support this.

It can now resolve aliases and lambdas properly.  This means 
things like this will work correctly.

module pack.test;
int foo() { return 0;}
int foo(int i) { return i+1; }
void foo(double d) { }

foreach(overload; __traits(getOverloads, pack.test, "foo"))
    writeln(__traits(codeof, overload);

Also, passing lambdas via template alias parameters works.  So 
something like this should work as well.

void foo(alias dg)() {
    writeln(__traits(codeof, dg));
}

void main() {
    foo!(x=>x+1)();
}


More information about the Digitalmars-d mailing list