I think this is a reasonable thing to ask for. Since P1064 was accepted, in C++20 we will be able to call virtual methods at compile time. The idea is to unify compile-time and run-time programming styles as much as possible---the fact that someone could achieve polymorphism at compile-time using CRTP was not a compelling reason to not accept P1064. Someone might want their multiple-inheritance-based design to work at compile time, and that might require virtual inheritance. The main objection I can see is that changing the language to allow it could be a bit complicated (what are all the consequences of changing the definition of "literal type" to include classes with virtual base classes?)

On Fri, May 31, 2019 at 10:59 PM Jack Adrian Zappa via Std-Proposals <std-proposals@lists.isocpp.org> wrote:
Perhaps you might be able to implement this in a CRTP manner, just like you could implement many constexpr functions like recursive ternary operation. However, I've been seeing many of the wonderful cppcon videos and am seeing that just because one can dig with spoons, doesn't mean that we should when a shovel is a much better tool (https://youtu.be/4AfRAVcThyA). Though, as CRTP is a static "inheritance", you'd have to use tuples instead of other homogenous containers.

I don't pretend to understand the inner workings of the compiler, but as a developer, I would think that anything is possible, it's just the level of difficulty and if the feature is deemed worth the trouble.


A

On Fri, May 31, 2019, 22:33 Jake Arkinstall via Std-Proposals, <std-proposals@lists.isocpp.org> wrote:
Immediate thought: this doesn't make sense to me. Can you provide a more detailed description of your particular use case? If it is just the inheritance of the I/O child classes then CRTP is the canonical solution. At least that way the type of the child class is known by the compiler, whereas the entire point of virtual inheritance is to allow flexibility at runtime.

As such, I don't think this is remotely possible apart from in the circumstances that only one type is possible (E.g. in a branch where the type is determined). If those circumstances are commonplace, virtual inheritance is likely avoidable.
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
http://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
http://lists.isocpp.org/mailman/listinfo.cgi/std-proposals


--
Brian Bi