C++ Logo


Advanced search

Re: [std-proposals] Chimeric Pointer

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Sun, 27 Nov 2022 12:26:31 -0500
On Sun, Nov 27, 2022 at 12:03 PM Phil Endecott via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> I think it would be possible to implement operator->* to make this
> possible:
> struct A { void fn_a(); };
> struct B { void fn_b(); };
> struct AB: A, B {};
> chimeric_ptr<A,B> p;
> p ->* &A::fn_a ();
> That's fractionally less typing than p.as<A>()->fn_a(). Is it any
> clearer? (Does it actually work - I've not tried to implement it!)

No and no. Operator precedence requires parentheses there:
Also, by requiring `fn_a` to be an addressable entity, you're preventing it
from being an overload set, or a template, or a static member function, or

I could imagine a core language change to make p -> A::fn_a equivalent
> to p ->* &A::fn_a, i.e. allowing the "redundant" *& to be elided. Would
> that conflict with other syntax?

I cannot imagine such a core-language change. Notice that `p->A::fn_a()` is
already valid C++ syntax.


Received on 2022-11-27 17:26:44