Dynamic templated virtuals - I still often want them
Alexandru Ermicioi
alexandru.ermicioi at gmail.com
Tue Jul 28 21:01:08 UTC 2020
On Thursday, 23 July 2020 at 02:38:27 UTC, Adam D. Ruppe wrote:
>
> But imagine if `serialize` actually got a virtual table entry,
> just like if it wasn't a template at all, but each child class
> automatically got an instance of it made for itself.
That will fail for at least one use case:
Consider class A that has templated virtual method do. It lives
in library X. Then we have class B : A that is in library Y. Now
application U has variable of type A that contains type B. At
some point U calls 'do' with an int. How should compiler proceed
with such situation given Y is available only in compiled version?
Virtual template methods could work if D would have generics
similar to Java, which are basically syntactic sugar for dynamic
casts.
Best regards,
Alexandru.
More information about the Digitalmars-d
mailing list