opDispatch to template members

Jacob Carlborg doob at me.com
Thu Dec 6 23:57:08 PST 2012


On 2012-12-06 22:49, Phil Lavoie wrote:
> I mean automatically dispatch to template members, not doing it in a
> case by case fashion (using template if clauses for example).
>
> Thanks

As Kenji said, doing something like this:

struct Outer {
   private Inner _inner;

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

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list