Two part question. Making a dynamic array of delegates, and taking in a delegate with unknown parameters as an argument .

Payotz via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Dec 1 15:51:19 PST 2016


So, to give context, I am trying to make an event manager for a 
game I'm making.
I was writing the "register()" method so I ran into a problem.

The register method will take in delegates as an argument, but 
those delegates have varied arguments themselves, so I can't 
really put anything there. I know that it's got something to do 
with templates so I tried my hand in it and came up with this:

void registerEvent(string event_name,T...)(T delegate() dg);

I know there's something missing in the way I did it, so I'll be 
glad for you folks to tell me what I'm missing.

And for the second part of the question, I can't seem to make a 
Dynamic Array where I could store the delegates taken in the 
"registerEvent" method. Closest thing I have gotten to is this:

private void delegate(T)(T args)[string] event;

which resulted in the compiler screaming Error signs at me.
So how does one do it?


More information about the Digitalmars-d-learn mailing list