hasStaticMember and enums
Steven Schveighoffer
schveiguy at gmail.com
Tue Sep 22 12:40:12 UTC 2020
On 9/22/20 6:12 AM, Jacob Carlborg wrote:
> On Monday, 21 September 2020 at 23:33:17 UTC, Steven Schveighoffer wrote:
>> I was confused today when I was looking to see if a particular field
>> name was a field of a struct and not a static member.
>
> You can use `tupleof` to access the fields. Combine that with
> `__traits(identifier)` to get the name of a field.
I don't have that though. I have a name.
I'm writing a meta-type that creates members for all fields using
opDispatch:
auto opDispatch(string name)() if (isField!(T, name))
So I could potentially loop through each member of tupleof and check if
the name matches, but I would prefer a more direct route.
-Steve
More information about the Digitalmars-d
mailing list