C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Simplify taking pointer to non-static member function

From: Oleksandr Pikozh <o.pikozh_at_[hidden]>
Date: Wed, 6 Mar 2024 14:16:50 +0200
I personally like the idea to allow a shorter way (or more ways) of getting
non-static member function address:

    class C {
      int f(char);
      static void g() {
        int C::*fp1(char) = &C::f; // allowed
        int C::*fp2(char) = &f; // forbidden but IMHO should be allowed
        int C::*fp3(char) = C::f; // forbidden and I don't care
        int C::*fp4(char) = f; // forbidden and I don't care
      }
    };

As for the proposed change of the expression type (so that `&C::f` would
contain pointer to `this`, i.e. in fact act as `std::bind_front(&C::f,
this)` instead) – I don't support that, IMHO that's too incompatible change.

On Tue, Mar 5, 2024, 20:02 ஜெய்கணேஷ் குமரன் via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> Remember: we're talking about querying information that you *already
> have*. The "this pointer of the current instance" is clearly available
> to whomever is writing `&class_name::function`. Besides your personal
> convenience, what's the point here?
>
> Besides personal convenience, there is no point, yes. Anyway, do consider
> much original suggestion of simply not needing to quality non-static member
> functions with class name, even if you do not consider this.
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2024-03-06 12:17:04