Reset all Members of a Aggregate Instance

Nordlöw via Digitalmars-d-learn digitalmars-d-learn at
Thu Dec 3 13:04:00 PST 2015


     class C
         // lots of members

and a function

     f(C c)

is there a generic way, perhaps through reflection, to reset 
(inside f) all members of `c` to their default values? Something 

     foreach(ref member; __traits(allMembers, c))
         member = typeof(member).init;

More information about the Digitalmars-d-learn mailing list