Pop quiz, what does this do?
Steven Schveighoffer
schveiguy at gmail.com
Wed Mar 3 16:53:26 UTC 2021
On 3/3/21 11:42 AM, Max Haughton wrote:
> On Wednesday, 3 March 2021 at 16:06:48 UTC, Steven Schveighoffer wrote:
>> The FieldNameTuple from std.traits returns a tuple of names of all the
>> fields that are present on a type instance.
>>
>> What about the result on things that can't have fields?
>>
>> import std.traits;
>>
>> interface I
>> {
>> int foo();
>> }
>>
>> pragma(msg, FieldNameTuple!I);
>>
>> Without looking up the docs, or trying it, what do you think it does?
>>
>> -Steve
>
> "" - difference between a field and a member I'm guessing
No, it's not. A member that's not a field doesn't normally produce
anything in the tuple.
Try this one:
interface I
{
int foo();
int bar();
}
-Steve
More information about the Digitalmars-d
mailing list