Trying to get type and name at compile time

Edwin van Leeuwen via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue May 24 08:01:33 PDT 2016


Hi all,

I am trying to get the type and name of a field at compile time, 
but can't get the following to work. Anyone any idea of why test 
is not of the type AliasSeq!(double, "x")?


```
import std.meta : AliasSeq;

struct Point { double x; double y; }

alias test = AliasSeq!(
     typeof(__traits(getMember, Point, "x")),
     "x"
);

// I expected AliasSeq!(double,"x")???
pragma(msg,test); // tuple((double), "x")

static assert(is(test == AliasSeq!(double,"x")));

void main() {}
```

Cheers, Edwin


More information about the Digitalmars-d-learn mailing list