More Compile-Time Reflection

"Nordlöw" per.nordlow at gmail.com
Fri Feb 28 15:35:46 PST 2014


On Friday, 28 February 2014 at 22:55:54 UTC, Adam D. Ruppe wrote:
> What specifically are you looking for? You can get names, 
> overloads, parameters, return values, and attributes of 
> struct/class methods with reflection today. See 
> __traits(allMembers), etc., and the phobos std.traits module.

See also x.tupleof property which returns a tuple of all the 
members of x, x being either a struct or class. Typical use

foreach (member; structure_or_class.tupleof)
{
     // perform some side-effect with member
}

/Per


More information about the Digitalmars-d mailing list