Thread overview | |||||
---|---|---|---|---|---|
|
March 14, 2015 get struct member names | ||||
---|---|---|---|---|
| ||||
Hi all, I am new to D and so far it is really great. I am wondering how to get the names of member variables in a struct or class. I haven't worked it out yet but this would enable metaprogramming like iterating over the members of the struct. I see in std.traits that you can get get MemberFunctionsTuple but nothing like MemberVariablesTuple. Charles |
March 14, 2015 Re: get struct member names | ||||
---|---|---|---|---|
| ||||
Posted in reply to Charles Cooper | __traits(allMembers, Struct) can do it. Get the free sample chapter from my book: https://www.packtpub.com/application-development/d-cookbook and it goes into more detail (I'm in a bit of a rush right now!) the sample link is under the picture |
March 14, 2015 Re: get struct member names | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | Wow, this is f***ing cool. http://dlang.org/traits.html#allMembers Thank you! On Saturday, 14 March 2015 at 14:54:27 UTC, Adam D. Ruppe wrote: > __traits(allMembers, Struct) can do it. > > Get the free sample chapter from my book: https://www.packtpub.com/application-development/d-cookbook and it goes into more detail (I'm in a bit of a rush right now!) > > the sample link is under the picture |
Copyright © 1999-2021 by the D Language Foundation