I'm refreshing some forgotten concept about pointer to function to create some kind of wrapper class to deal with callback calls.
After surf in google I found this simple but interesting post http://blog.coldflake.com/posts/C++-delegates-on-steroids/
So far I understand almost everything except this
T::*TMethod
I can remember the meaning of ::*, you can see that in many part of the post, here is the first time that author use it
class Delegate
{
typedef void (*Type)(void* callee, int);
public:
Delegate(void* callee, Type function)
: fpCallee(callee)
, fpCallbackFunction(function) {}
template <class T, void (T::*TMethod)(int)> <<<<<<First time
static Delegate from_function(T* callee)
{
Delegate d(callee, &methodCaller<T, TMethod>);
return d;
}
void operator()(int x) const
{
return (*fpCallbackFunction)(fpCallee, x);
}
private:
void* fpCallee;
Type fpCallbackFunction;
template <class T, void (T::*TMethod)(int)>
static void methodCaller(void* callee, int x)
{
T* p = static_cast<T*>(callee);
return (p->*TMethod)(x);
}
};
So far, I understard de concept of how it work but I can't remember the meaning of ::*
I know that propablythisisavery basic and silly question, so be nice, please.
Best Regards