Template method in interfaces

Arafel via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 10 08:39:19 PDT 2016


On Wednesday, 10 August 2016 at 15:25:40 UTC, Lodovico Giaretta 
wrote:
> Because templated functions cannot be virtual, it follows that 
> I.func is final. Having no body, the compiler thinks that its 
> body will be found by the linker in another object file, but 
> this does not happen, so the linker complains.
> Being I.func final, C.func just hides it, so you would not 
> incur any problem if you called func explicitly on an object of 
> type C.
>
> So what you found is not a bug, but some unintuitive behaviour 
> due to templated functions being implicitly final and forward 
> declarations. Maybe the compiler should emit a warning about 
> implicitly-final functions in interfaces.

Would it even make sense to "force" (deprecation warning) a 
"final" keyword in any implicitly-final function (I wasn't even 
aware of those, I have to admit)? It would make things much 
clearer, like with "override"...


More information about the Digitalmars-d-learn mailing list