Method function pointer template without naming class type

Viewed 454

Consider this template function, invoking a method of an object of class T.

template<class T, void (T::*Method)()>
void circuitousInvoke(T* callee) {
    (callee->*Method)();
}

Example:

struct A {
    void test() {};
}

circuitousInvoke<A, &A::test>(new A);

As the type T is already known to circuitousInvoke from parameter callee, is there a way to avoid typing this type?

circuitousInvoke<&A::test>(new A);

EDIT

This question refers to template functions only. Inheritance and other class based solutions are not suitable in this case. (In my project using a wrapper object would be more worse than typing an additional name.)

1 Answers
Related