C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Chimeric Pointer

From: Peter Olsson <dataapa_at_[hidden]>
Date: Fri, 25 Nov 2022 11:50:23 +0100
I think some people are misunderstanding this feature. A variant (even
if you use pointers) or overloading cannot work because you don't want
ONE OR THE OTHER, you want BOTH.

I'm thinking, is this really too bad?

    void Red(wxControl *const pC, wxTextEntry *const pT);

Can't you just think of it as the function taking a wxControl and a
wxTextEntry? Does it matter if they are two different objects or the
same?

If I wanted to implement the wxControl and wxTextEntry interfaces and
call your function Red, shouldn't I be allowed to do it either way?

class A : wxControl, wxTextEntry
{
  ...
    void foo() { Red(this, this); }
  ...
};

or

class B
{
  ...
    struct MyControl : wxControl { ... };
    struct MyTextEntry : wxTextEntry { ... };
    void foo()
    {
        MyControl control{...};
        MyTextEntry textEntry{...};
        Red(&control, &textEntry);
    }
  ...
}

Received on 2022-11-25 10:50:36