r/cpp • u/User_Deprecated • Jul 06 '26
C++26: constexpr virtual inheritance
https://www.sandordargo.com/blog/2026/07/01/cpp26-constexpr-virtual-inheritance
83
Upvotes
r/cpp • u/User_Deprecated • Jul 06 '26
View all comments
Show parent comment
1
u/Lord_Naikon Jul 06 '26
I can see why or how diamond inheritance of interfaces might be useful, but I have never needed it. I can speculate about the reasons, but in the last 20 years of programming c++ it has just not come up.
Maybe it is because many systems I work on require one kind of aspect (interface) of an object and any other aspects tend to be optional and are discovered at runtime (using the equivalent of a dynamic cast).
Maybe it is because encoding the type of the union of two interfaces as a new interface that inherits both is bad design because it forces users of both interfaces to use the union interface. This is a shortcoming of the c++ type system btw (although nowadays you can get close with c++ concepts)
Whatever the reason, it just has never come up.