Hey Thiago, have you checked my concept based solution above? 


On Fri, Nov 25, 2022, 18:25 Thiago Macieira via Std-Proposals <std-proposals@lists.isocpp.org> wrote:
On Friday, 25 November 2022 08:45:41 PST Arthur O'Dwyer via Std-Proposals
wrote:
> Frederick's suggested solution was to just make it work by magic:
>
>     void Red(__chimerical(Control, TextEntry) *p) {
>         p->SetBackgroundColor();  // this means Control::SetBackgroundColor
>         p->SetValue("pending");  // this means TextEntry::SetValue
>     }
[snip]

Please ignore my earlier replies today, before reading what the feature was
actually trying to achieve.

A third alternative, in addition to the two that Arthur suggested, is a simple
pointer wrapper that stores one pointer to each of the requested sub-objects
of the object.

template <typename... Bases>
struct chimeric_pointer : chimeric_pointer_storage<Base>...
{
    template <typename T>
    chimeric_pointer(T *obj) : chimeric_pointer_storage<Base>(obj)... {}
};
or something, plus a set of std::get or get members to extract each of the
sub-objects as desired, to write something like:

void Red(chimeric_pointer<wxControl, wxTextEntry> p)
{
    p.get<wxControl>()->SetBackgroundColor();
    p.get<wxTextEntry>()->SetValue("pending");
};

This idea would have a size of N * sizeof(void*) for N bases. I don't know if
it's possible to shrink it without a getter that is per chimeric pointer and
per complete object type.

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



--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals