Shouldn't __traits return Tuples?

Trass3r mrmocool at gmx.de
Tue Mar 31 06:14:27 PDT 2009


Max Samukha schrieb:
>> "variable main.main.i voids have no value"
> 
> __traits is buggy.
> 
> template isFunction(C, string member)
> {
>     enum isFunction = is(typeof(mixin("C." ~ member)) == function);
> }
> 
> void main()
> {
>     //SpinLock lock;
> 
>     enum members = __traits(allMembers, Class);
>     foreach (i; Sequence!(members.length))
>     {
>         static if (isFunction!(Class, members[i]))
>         {
>             foreach (j; __traits(getVirtualFunctions, Class,
> members[i]))
>                 writefln(members[i], ": ", typeid(typeof(j)));
>         }
>     }
> } 
> 

Yeah extreeemely buggy. dmd also crashes if that enum members is changed 
to const members or invariant members.

In fact, what I'm trying to do is getting all the functions of a given 
class and checking their parameters for correctness.



More information about the Digitalmars-d mailing list