digitalmars.D - Variatic Templates
- Joshua Cearley (20/20) May 14 2005 Since Delegates and Functions are not interchangeable in D, I'm working
Since Delegates and Functions are not interchangeable in D, I'm working on an encapsulation system that allows you to pass an EventContainer which will house either a Delegate or a Function on its own. This simplifies the event system since there doens't have to be a function to connect to something of type Function and another to connect to something of type Delegate. They both just connect to EventContainer. To make it generic and reusable, I decided to use a template. This is all fine up until you have to deal with parameters. The problem is I can't use a va_list in the template instantiation. I tried using a static function that simply takes its input arguments and returns its va_list, but it doesn't work. Is there any way to make a "generic delegate" via templates? I want to be able to allow the user to set the ReturnType and Arguments when instantiating the template (usually using an alias) and be able to run EventContainer.Run( parameters ). I thought about just having the delegate type as part of the template, but then you can't wrap the arguments in the Run command. Any help would be greatly appreciated. -JC BlackCrystal Software "Because all the good mottos are already taken!"
May 14 2005