On Wednesday, 17 June 2020 at 11:31:09 UTC, jmh530 wrote:
On Wednesday, 17 June 2020 at 10:04:59 UTC, Atila Neves wrote:
[...]

Cool.

[...]

If I'm understanding you correctly, you could modify Polymorphic (and a similar change to VirtualTable) to

struct Polymorphic(Interface, InstanceAllocator = DefaultAllocator) if(is(Interface == interface) || is(Interface == class) || is(Interface == struct))

and the current functionality would still work.

However, compared to normal inheritance, it would be missing the "base" class's member variables that don't exist in the "derived" one. You also couldn't call the "base" class member functions. Polymorphic is assuming the member functions are all implemented in the instance passed to it, correct?

I think these questions are good motivators for making it interface-only since then I don't have to check for data definitions.

Reply via email to