Consider the following hypothetical example:
template<typename T, typename R, typename... Ps>
R call(T& t, R (T::*method)(Ps...), Ps... ps){
return (t.*method)(ps...);
}
struct A{
int f(int i) const {return i;}
};
A a;
Then call(a, &A::f, 3)
wont compile, because f
is const. Can I make call
work without providing the following overload:
template<typename T, typename R, typename... Ps>
R call(T& t, R (T::*method)(Ps...) const, Ps... ps){
return (t.*method)(ps...);
}