Why is the ampersand in `std :: is_member_function_pointer`?

The usage example std::is_member_function_pointer

on cppreference is using the ampersand and I have some difficulty understanding the syntax.

#include <type_traits>

class A {
    void member_function() { }
};

int main()
{
    // fails at compile time if A does not contain member_function as a function.
    static_assert(std::is_member_function_pointer<decltype(&A::member_function)>::value,
                  "Class does not contain member."); 
}

      

What is the meaning &A::member_function

and do A::member_function

matters (and if so, what is the difference)?

Also, does it work std::is_member_function_pointer

with function templates?

+3


source to share


1 answer


This expression

&A::member_function

      



literally means a pointer to a member function. It is used and used to get a pointer. For a member function.

+3


source







All Articles