When I want to have member function as template argument, is there a way to templetize it without providing Caller type?
struct Foo
{
temp
No, not as you want it. Caller could be deduced if
the pointer to member function were an parameter, not a template parameter. Eg:
template <class Caller>
void call(Caller * c, void (Caller::*Func)(int)) { (c->*Func)(6); }
it was known beforehand. For example, you could make the call look like this:
f.arg(this).call<&Bar::printNumber>();
The call function would look similar to this:
template <class Arg>
struct Binder
{
template<void (Arg::*Func)(int)>
void operator()() const {
...
}
};
The arg function would be easy to write (in your case it would return Binder<Bar>, where Bar is deduced from this).
Not very convenient, IMHO.