class scope virtual template functions
janderson
askme at me.com
Sat May 31 21:48:36 PDT 2008
Chris Wright wrote:
> 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.
I agree that having virtual templates in the language would be nice. I
don't like using workaround because they are less intuitive.
-Joel
More information about the Digitalmars-d
mailing list