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: Mon, 8 Jan 2024 18:16:46 +0000
On Monday, January 8, 2024, Giuseppe D'Angelo via Std-Proposals <
std-proposals_at_[hidden]> wrote:
>
>
>> std::invoke_func_as_memfunc(pf, &myvar, 56.7L);
>>
>
> If you have to use a special facility to invoke the
> faux-pointer-to-function anyhow, then what's the point of
> "memfunc_to_func"? It sounds like a terrible idea, as it would be
> completely type unsafe.
>


I had hoped two things:

(1) That a member function pointer could be reduced to just a function
pointer
(2) That the address of the implementation of a virtual function could be
ascertained without invoking the member function

Looking at how member function pointers are implemented though on some
computers (e.g. v-table offset + delta this), it seems that goal No. 1
wouldn't be attainable without also keeping the type information.

So I'm scrapping this idea and will go back to peddling std::unaligned.

Received on 2024-01-08 18:16:48