On the type of a pointer to a class method using deducting this
The type of a pointer to a class method using deducting this matches the type of a pointer to a free function:
#include
struct TA
{
void Foo(this auto&& self)
{
std::cout << "Foo call\n";
}
};
void test_TA()
{
TA a;
void (*fun_ptr)(TA&) = &TA::Foo;
(*fun_ptr)(a);
}
int main()
{
test_TA();
}
This is somewhat counter-intuitive.
Why was this design adopted? Is there any difficulty for compilers in using the ordinary type of a pointer to a class method (void (TA::*mem_ptr)() &) in this case? It would be intuitive.