The return type of mem_fn
and bind
is unspecified. That means, depending on the arguments a different kind of object is returned, and the standard doesn't prescribe the details how this functionality must be implemented.
If you want to find out what the type is in a particular case with a particular library implementation (for theoretical interest, I hope), you can always cause an error, and get the type from the error message. E.g:
#include <functional>
struct X
{
double method(float);
};
int x = std::mem_fn(&X::method);
9 Untitled.cpp cannot convert 'std::_Mem_fn<double (X::*)(float)>' to 'int' in initialization
In this case, note that the type's name is reserved for internal use. In your code, you shouldn't use anything with a leading underscore (and a capital letter).
In C++0x, I suppose the return type would be auto
:)
auto fun = std::mem_fn(&ClassA::method);