C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Chimeric Pointer

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 24 Nov 2022 15:41:19 -0800
On Thursday, 24 November 2022 14:46:32 PST Frederick Virchanza Gotham via Std-
Proposals wrote:
> I've written a 2-page PDF file to describe my new idea of chimeric
> pointers. I've tried to attach it to this email, and also you can
> download it from my webspace here:
>
> http://www.virjacode.com/download/chimeric_pointer.pdf
>
> Here's a excerpt from the PDF:
>
> "When you apply the ‘->’ operator to a chimeric pointer and then try
> to access a member object or a member function, the compiler tries to
> find the member in all the base classes"

Instead of

void Red( chimeric_pointer<wxControl,wxTextEntry> p )
{
  p->SetBackgroundColour( *wxRED );
  p->SetValue("pending");
  p->Refresh();
}

Write:
void Red(std::Variant<wxControl,wxTextEntry> &p )
{
  std::visit(([](auto &p) {
    p/SetBackgroundColour( *wxRED );
    p.SetValue("pending");
    p.Refresh();
 }, p);
}
-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2022-11-24 23:41:21