The example of use of std::is_member_function_pointer on cppreference uses an ampersand and I have some difficulties to understand 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 of &A::member_function and do A::member_function has a meaning (and if yes, what is the difference) ?
Furthermore, does std::is_member_function_pointer work with function templates ?
This expression
&A::member_function
literally means a member function pointer. The & is used to get the pointer.to a member function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With