tupleof of class instance... but enumerate _all_ the instance variables
Andy Valencia
dont at spam.me
Mon Jun 30 16:37:01 UTC 2025
On Saturday, 28 June 2025 at 10:41:47 UTC, Nick Treleaven wrote:
> static foreach (field; B.tupleof)
> {{
> enum s = __traits(identifier, field);
> pragma(msg, s);
> // access runtime field
> __traits(getMember, d, s)++;
> }}
One last question, if you would? Why the double open braces? I
tried, and got:
tst57.d(26): Error: declaration `tst57.main.s` is already defined
tst57.d(26): `variable` `s` is defined here
if I changed to a single open brace?
Thanks again,
Andy
More information about the Digitalmars-d-learn
mailing list