digitalmars.D.learn - How do I filter out this type?
- Dr.No (22/22) Jun 22 2018 In the below code, "A[] found" is never printed. What's the
- Steven Schveighoffer (4/5) Jun 22 2018 static if(is(typeof(__traits(getMember, B, field)) == A[]))
- Dr.No (3/10) Jun 23 2018 oh, I'm a bit embarrassed. haha Thanks anyway!
In the below code, "A[] found" is never printed. What's the proper way to check for this type? import std.stdio; import std.traits : FieldNameTuple; class A { } class B { string foo; string baa; A[] list; } void main() { static foreach(field; FieldNameTuple!B) { static if(is(typeof(__traits(getMember, B, field) == A[]))) { writeln("A[] found"); } } writeln("done"); }
Jun 22 2018
On 6/22/18 1:07 PM, Dr.No wrote:static if(is(typeof(__traits(getMember, B, field) == A[])))static if(is(typeof(__traits(getMember, B, field)) == A[])) Note the slight change in parentheses. -Steve
Jun 22 2018
On Friday, 22 June 2018 at 17:20:03 UTC, Steven Schveighoffer wrote:On 6/22/18 1:07 PM, Dr.No wrote:oh, I'm a bit embarrassed. haha Thanks anyway!static if(is(typeof(__traits(getMember, B, field) == A[])))static if(is(typeof(__traits(getMember, B, field)) == A[])) Note the slight change in parentheses. -Steve
Jun 23 2018