loop through specific class members

Trass3r mrmocool at gmx.de
Tue Jan 20 11:13:00 PST 2009


Jarrett Billingsley schrieb:
> On Tue, Jan 20, 2009 at 10:29 AM, Trass3r <mrmocool at gmx.de> wrote:
>> It seems like there is no way to automatically get the class methods in D1
>> currently?!
>> __traits isn't supported, std.traits doesn't give anything usable, .tupleof
>> only gets the fields (plus only giving an ExpressionTuple for classes).
> 
> You're correct.  __traits was introduced in D2 mostly because D1's
> compile-time introspection is so paltry.

Yeah, __traits works quite well to get the function names, but I still 
can't manage to get the corresponding function object to pass it to 
ParameterTypeTuple (for checking the parameters for correctness).

Tried using ClassInfo's getMembers function but that apparently doesn't 
work.

Base base = new Base;
auto members = __traits(allMembers, typeof(base));
foreach(m; members)
	writefln(base.classinfo.getMembers(m).length);

gives 0 for every member :(


More information about the Digitalmars-d-learn mailing list