opDispatch to template members

Phil Lavoie maidenphil at hotmail.com
Thu Dec 6 13:42:12 PST 2012


Greetings,

Given the following code:

struct Inner {

   void fun1() {}
   void fun2( string toto ) {}
   string fun3() { return "tata"; }
   string fun4( string tutu ) { return "this is going too far"; }

   void fun5( string ohOh )() {}

}

struct Outer {
   private Inner _inner;

   auto opDispatch( string method, T... )( T args ) {
     return mixin( "_inner." ~ method )( args );
   }

}

void main( string[] args ) {
   Outer outer;
   outer.fun1();
   outer.fun2( "some string" );
   auto zeString = outer.fun3();
   auto zeOtherString = outer.fun4( zeString );
   outer.fun5!"popo"(); //No compilo amigo

}

Is it possible/desirable to ever get opDispatch to delegate to a 
template member function?

Thanks


More information about the Digitalmars-d mailing list