C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Chimeric Pointer

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Fri, 25 Nov 2022 12:25:48 -0500
On Fri, Nov 25, 2022 at 12:12 PM Thiago Macieira via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> On Friday, 25 November 2022 01:45:01 PST Frederick Virchanza Gotham via Std-
> Proposals wrote:
> > That forward slash is supposed to be a dot, right? Anyway if I try to
> > compile the following standalone function:
> >
> > void Red( std::variant<wxControl,wxTextEntry> &p )
> > {
> > std::visit(([](auto &p) {
> > p.SetBackgroundColour( *wxRED );
> > p.SetValue("pending");
> > p.Refresh();
> > }, p);
> > }
> >
> > then I get:
> >
> > cannot declare field
> > '__gnu_cxx::__aligned_membuf<wxTextEntry>::_Tp2::_M_t' to be of abstract
> > type 'wxTextEntry'
>
> Then use std::variant<wxControl *,wxTextEntry *> instead of a variant of the
> actual types.

That wouldn't work either. Remember: the feature is to have it be
inherited from *both*, not one or the other. `variant` is the wrong
tool.

I understand that wxWidgets is not the most popularly used GUI API in
C++. But the proposal contains an actual inheritance diagram that
clearly spells out what's going on here. How do you keep
misunderstanding it?

So let's spell this out even more clearly:

There are two classes U and V which are base classes intended to be
inherited from. There are many classes which inherit from both, but
there are many other classes that only inherit from one of them.

The desire is to have a function F which takes a pointer to any type
that inhertis from both U and V and to use it directly to access
members of either U or V *without* having F be a template.

Received on 2022-11-25 17:27:52