Consider this function templateby calling an object method 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 you know, the type T is already known as circousInvoke from the parameter callee, is there a way to avoid entering this type?
circuitousInvoke<&A::test>(new A);
EDIT
This question applies only to template functions. Inheritance and other class-based solutions are not suitable in this case. (In my project, using a wrapper object will be worse than spelling an extra name.)
source
share