This is probably trivial or impossible Code Introspection...

WhatMeWorry via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Sep 20 10:34:42 PDT 2015


On Sunday, 20 September 2015 at 05:50:16 UTC, Ali Çehreli wrote:
> 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

Should of tried this earlier, but just for grins I threw in 
another trait: EnumMembers.

import std.traits;

struct S { int x; float y; }
static assert(FieldNameTuple!S == TypeTuple!("x", "y"));  // FAILS

enum E : int { a, b, c }
int[] abc = cast(int[]) [ EnumMembers!E ];    // WORKS


The EnumMembers from traits compiles/links fine.  Ergo, it must 
be I've got an old version of D Lib?  I see on the web site that 
D Lib is now at 2.068.1

Looking at my old folders, I see a 
dmd-2.066_0-OneClickWindowInstaller folder that I must of used 
around October 2014 for my initial install.  Is there a tool or 
subsystem that I can use to see the history or FildNameTyple?

Now, I need to figure out how to upgrade my D, DMD or Phobos (not 
sure about terminology) without disturbing my Visual D 
environment.  Wish me luck :)

Thanks for helping me with these beginner questions.







More information about the Digitalmars-d-learn mailing list