I recently discovered that the function pointer syntax can be simplified by using the following helper class:
template<typename Sig>
struct Fun {
typedef Sig* Ptr;
};
It allows me a pointer to the void()following:
typedef Fun<void()>::Ptr fun_ptr;
fun_ptr f = foo;
I would like to create a similar utility for creating typedef to member function pointers. This will allow you to use the following syntax:
struct Foo {
void bar() {}
};
typedef MemFun<Foo, void()>::Ptr bar_type;
bar_type b = &Foo::bar;
However, I cannot understand the typedef syntax:
template<class T, typename Sig>
struct MemFun {
};
Can anyone help?
source
share