class scope virtual template functions
Chris Wright
dhasenan at gmail.com
Sat May 31 06:26:05 PDT 2008
janderson wrote:
> Sorry, I haven't actually tried this example. Its an C++ trick I've
> used for other purposes. I think it looks something like this:
>
> class TemplateMaker
> {
> TemplateMakera(delegate) { record of stuff ... } //This might be a
> template too, can't remember. Maybe a reinterpret cast somewhere too.
> void opCall(T...)(T arg) { delegate->recoredcallback(arg); }
> }
>
> I'm sure given enough time it could be done in D like C++. I don't want
> to put in the effort though atm.
>
> -Joel
Delegates can work. But you have to know the arguments to the template
in advance.
Everything I can think of to implement virtual templates requires
virtual templates. With the exception of hacking the compiler, which
would provide a means of providing virtual templates. It's a
straightforward matter, so it wouldn't require redesign like const,
though the initial effort might well be greater.
More information about the Digitalmars-d
mailing list