C++ Logo


Advanced search

Re: [std-proposals] Chimeric Pointer

From: Thiago Macieira <thiago_at_[hidden]>
Date: Sat, 26 Nov 2022 18:40:15 -0800
On Saturday, 26 November 2022 16:01:11 PST Marian Darius via Std-Proposals
> And it's sizeof(void*) because it *is* a void*

Your code doesn't work because this assumption is incorrect.

Think of two base sub-objects in two different classes with different offsets:

class wxControl1: public wxTextEdit, public wxControl { ... };
class wxControl2: public wxControl, public wxTextEdit { ... };

You must either store the actual bases or have a way to restore the offsets
from the top-of-object void pointer. That's not static_cast.

It can be a dynamic_cast, but not on a void * because the address of the
vtable pointer isn't know there either.

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

Received on 2022-11-27 02:40:17