Iteration over structure fields and properties

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Fri Sep 8 04:17:56 PDT 2017


On 2017-09-07 09:22, Void-995 wrote:

> Would it work with:
> @property int propertyNameA()

No, for that you need the traits getFunctionAttributes [1] (I think all 
functions are returned) and getFunctionAttributes [2].

> And how to get key names then? As I remember tupleof return tuple of 
> fields only, at least what I got how it works.

You index the tuple and use the "identifier" trait.

[1] https://dlang.org/spec/traits.html#getVirtualFunctions
[2] https://dlang.org/spec/traits.html#getFunctionAttributes

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list