C++ a way to have a typedef template to a member function?
c++, member, pointers, templates, typedef
Solution
You could try wrapping it in a struct like this:
template <class T>
struct method_ptr
{
typedef void (T::*Function)(Parameters p);
};
class A
{
public:
void foobar(Parameters);
};
// ...
method_ptr<A>::Function pfoobar = &A::foobar;
Problem
Title pretty much says it all! Is there any pretty/simple way to do this? Since function pointers can't point to member functions and a member function needs to know the class the members belong to but in this case there is no such information since the class the function comes from will differ. Only standard library please! ``` template <class A> typedef void (A::*Function)(Parameters p); ```