digitalmars.D.learn - Problem using __traits
- Daniel Ribeiro Maciel (23/23) Nov 07 2008 I am having a problem trying to enumerate then call a method of a class.
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
Nov 07 2008