Assign any event kind to a single templatized function ?
    Basile B. via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Mon Sep  5 06:44:53 PDT 2016
    
    
  
It's almost a "yeah". However this doesn't work with ref 
parameters. Any idea how to make this work, keeping the 
simplicity of the concept ?
°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
module runnable;
import std.stdio;
struct Foo
{
     void delegate(int) event1;
     void delegate(int,int) event2;
     void delegate(int,ref int) event3;
}
struct Handler
{
     void handle(A...)(A a){writeln(a);}
     void handleref(A...)(/*auto ref*/ A a){writeln(a);}
}
void main(string[] args)
{
     import std.traits;
     Foo foo;
     Handler handler;
     foo.event1 = &handler.handle!(Parameters!(foo.event1));
     foo.event2 = &handler.handle!(Parameters!(foo.event2));
     foo.event3 = &handler.handleref!(Parameters!(foo.event2)); // 
?
}
°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
    
    
More information about the Digitalmars-d-learn
mailing list