This is probably trivial or impossible Code Introspection...

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Sep 19 22:50:16 PDT 2015


On 09/19/2015 10:30 PM, H. S. Teoh via Digitalmars-d-learn wrote:
> On Sun, Sep 20, 2015 at 05:21:03AM +0000, WhatMeWorry via Digitalmars-d-learn wrote:
> [...]
>> Thanks.  But now I have an even more fundamental problem.  I keep
>> getting a FieldNameTuple is not defined.  But I've clearly got the
>> import statement.  I even copied the example from Phobos verbatim:
>>
>> import std.traits;
>>
>> struct S { int x; float y; }
>> static assert(FieldNameTuple!S == TypeTuple!("x", "y"));
>
> You need to use is(...) when comparing types:
>
> 	static assert(is(FieldNameTuple!S == TypeTuple!("x", "y")));
>
> HTH,
>
>
> --T
>

True but ever-confusingly, they are not types. :) It works without the 
is expression. Otherwise, we need to add typeofs as well:

static assert(is(typeof(FieldNameTuple!S) == typeof(AliasSeq!("x", "y"))));

Ali



More information about the Digitalmars-d-learn mailing list