FieldNameTuple!T and std.traits.Fields!T not empty for interfaces

Steven Schveighoffer schveiguy at gmail.com
Thu Jun 6 20:49:05 UTC 2019


On 6/6/19 4:43 PM, Steven Schveighoffer wrote:
> On 6/6/19 4:22 PM, Amex wrote:
>> FieldNameTuple!T
>> std.traits.Fields!T
>>
>> are non-empty when T is an interface!
>>
>> An interface cannot contain fields and yet these return non-zero and 
>> screws up my code. While I can filter for interfaces it makes me 
>> wonder what else may slip through?
>>
>> Is it a bug or what is going on?
> 
> Can you provide code to demonstrate? I get no fields when I do this:
> 
> interface I
> {
> }
> 
> import std.traits;
> pragma(msg, FieldNameTuple!I);
> 

Oh wait! It's not empty, it has an empty string as a single member! 
That's definitely a bug.

-Steve



More information about the Digitalmars-d-learn mailing list