How do I check if this field is of this template struct?

Paul Backus snarwin at gmail.com
Fri Mar 19 08:54:50 UTC 2021


On Friday, 19 March 2021 at 07:14:46 UTC, Jack wrote:
> give below template struct, how can I list the members x, y and 
> z? I've tried something with OriginalType and TemplateOf but no 
> luck... it seems if I do foo!"str1" the "str1" became "part of 
> type"? give .stringof from typeof(__traits(getMember, foo, 
> field)) I thought the type would be foo!string or something.

You want std.traits.isInstanceOf:

     static if(!isType!m && isInstanceOf!(foo, typeof(m)))


More information about the Digitalmars-d-learn mailing list