You can avoid explicitly mentioning the full type through such a set of functions:
template <class... Params, class R>
auto ovl(R(*f)(Params...)) {
return f;
}
template <class... Params, class R, class T>
auto ovl(R(T::*f)(Params...)) {
return f;
}
template <class... Params, class R, class T>
auto ovl_const(R(T::*f)(Params...) const) {
return f;
}
Usage is as follows, providing the argument types of the targeted function:
auto ptr = ovl<int>(&Foo::bar);
Overloads for varargs, volatile
, ref-qualified, etc. member functions are left as an exercise for the reader.