Templated member functions in interfaces

Jason House jason.james.house at gmail.com
Wed Apr 18 18:36:10 PDT 2007


Jarrett Billingsley wrote:
> "Jason House" <jason.james.house at gmail.com> wrote in message 
> news:f06cse$h1b$1 at digitalmars.com...
>> Here's a simplified version of the code I'm trying to get working. 
>> Honestly, I didn't expect it to work, but I was hoping...
>>
>> Is there any hope for this style of usage to work?  I'm pleasantly 
>> surprised by it compiling at all.  In the full implementation, the 
>> templated calls to X occur after a few more layers of obfuscation.  If the 
>> below code really does compile and link correctly, I can give a more 
>> complex example.
> 
> It might compile, but it might not do what you expect it to.  Templated 
> member functions (and interface methods) are never virtual and therefore 
> cannot participate in polymorphism.  :\ 
> 
> 

That seems to imply that having a variable of interface type should not 
be allowed if that interface contains templated member functions...


More information about the Digitalmars-d-learn mailing list