C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Allow conversion of memfunc pointers to func pointers

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Sat, 6 Jan 2024 12:14:34 +0000
On Sat, Jan 6, 2024 at 12:05 PM Frederick Virchanza Gotham wrote;
>
> Even though the "offset
> for this" is lost when "std::memfunc_to_func" is invoked, it could be
> regained when "std::invoked_func_as_memfunc" is invoked (as it can be
> determined from the type of the 2nd parameter -- i.e. the pointer to
> the object). This might even be an enhancement as it means the 'this'
> pointer will be correctly adjusted no matter what object you give it
> (i.e. you're not limited to the type that was passed to
> 'std::memfunc_to_func').


And therefore, even on implementations that use thunks,
"std::memfunc_to_func" should not return the address of the thunk, but
rather it should return the address of the bonafide function. Then
it's the job of "std::invoke_func_as_memfunc" to adjust the 'this'
pointer where necessary.

Received on 2024-01-06 12:14:43