While experimenting with auto and function pointers I notice a strange behavior
class Test
{
public:
void Func(){}
};
static constexpr const auto member_ptr1{ &Test::Func }; // compile fine
static constexpr const void(Test::*member_ptr2)(void) { &Test::Func }; // ERROR : cannot convert from void(Test::*)(void) to const void(Test::* const)(void)
I understand that, in the case of member_ptr2, the compiler complain about not finding a function with the signature const void Func() , but it should trigger the same error for member_ptr1.
So what does the compiler do under the hood with member_ptr2 ?
Bonus question : what does const means right after Test::* ? I notice that in the compiler output.
Second bonus question : When using function pointers is there any difference between constexpr const auto member_ptr1{...} and constexpr auto member_ptr1{...} ?