I am having a problem trying to enumerate then call a method of a class.

I have the following situation

class Foo
{
   void bar () { writefln( "hello" ); }
}

void traitsTest( TClass, string name )( TClass foo )
{
   foreach( method; __traits( allMembers, TClass ) )
   {
      writefln( method );
      __traits( getMember, foo, __traits( getVirtualFunctions, TClass, method 
)[0] )();
   }
}

void main()
{
  Foo foo;
  traitsTest!( Foo, "foo" )( foo );
}

but I am getting "Error: string expected as second argument of __traits 
getVirtualFunctions instead of method" at line: __traits( getMember, foo, 
__traits( getVirtualFunctions, TClass, method )[0] )();

What am I doing wrong?

Best Regards,
Daniel

Reply via email to