www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Help with "cannot alias an expression" compile error

I'm trying to do some form of reflection abstraction, here's my sample code:

import std.meta;

struct Fields(T)
     private static alias toField(alias e) = Field!(__traits(identifier, 
     alias fields = staticMap!(toField, T.tupleof);

     static alias map(alias F) = staticMap!(F, fields);
     static alias filter(alias pred) = Filter!(pred, fields);

struct Field(string n)
     enum name = n;

struct Foo
     int a;

void main()
     Foo value;

     enum toName(alias e) = e.name;
     enum pred(alias e) = true;

     alias a = Fields!(Foo).filter!(pred); // works
     alias b = Fields!(Foo).map!(toName); // works

     alias c = Fields!(Foo).init.filter!(pred); // works
     alias d = Fields!(Foo).init.map!(toName); // Error: alias d cannot 
alias an expression Fields().tuple("a")

Alias "a" and "b" compiles just fine. Alias "c" compiles as well but not 
alias "d", which I don't understand why. I'm fully aware that it's not 
possible to alias an expression, but what I want is to alias the tuple 
of strings that is returned.

/Jacob Carlborg
Sep 19 2016