C++ Logo


Advanced search

Re: [std-proposals] Extensible vtables -- Ensuring ABI isn't broken

From: Thiago Macieira <thiago_at_[hidden]>
Date: Sun, 18 Feb 2024 10:14:28 -0800
On Saturday, 17 February 2024 14:58:12 PST Frederick Virchanza Gotham via Std-
> I wonder could we somehow mark a class as 'extensible' to indicate
> that the vtables should be laid out in such as way as to allow for the
> extending of classes in the future? For example, the vtable for
> IKeyboard could instead be:

Yes, but it's an ABI change, unless it's an opt-in.

It will probably involve another level of indirection which in turn means
there's a runtime cost associated with it. Which is another reason for it to
be opt-in. Is this useful generally enough to be part of the standard?

You can already achieve this today with a has-a relationship and wrapping the
inner's virtual methods with inlines on the outer class. It's just

Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2024-02-18 18:14:31