How does the template parameter of std::function work? (implementation)
问题 In Bjarne Stroustrup 's home page (C++11 FAQ): struct X { int foo(int); }; std::function<int(X*, int)> f; f = &X::foo; //pointer to member X x; int v = f(&x, 5); //call X::foo() for x with 5 How does it work? How does std::function call a foo member function ? The template parameter is int(X*, int) , is &X::foo converted from the member function pointer to a non-member function pointer ?! (int(*)(X*, int))&X::foo //casting (int(X::*)(int) to (int(*)(X*, int)) To clarify: I know that we don't