C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Optimize away VTBL when using single inheritance

From: Sebastian Wittmeier <wittmeier_at_[hidden]>
Date: Sat, 25 Nov 2023 21:47:00 +0100
It is not about single inheritance (vs. multiple inheritance), but about whether more than one implementation of a function someVirtualFunc() exists directly in the interface class (if non-abstract) or within one of the derived classes. If you mean by 'single inheritance' that only one class derives from the (abstract) interface, then you would have to somehow tell within the source code. I cannot imagine a direct nice syntax. Something like listing the names of all possible derived classes within the declaration of interface? Perhaps it would be simpler to replace the definition of interface with an alias to Factory in release builds: using interface = Factory; Then interface* would always be a Factory*. -----Ursprüngliche Nachricht----- Von:Smith, Jim via Std-Proposals <std-proposals_at_[hidden]> In cases where single inheritance is used i->someVirtualFunc() would be optimized to a direct call on the object without any VTBL operation.

Received on 2023-11-25 20:47:02