You need an overload set object. This is an object that represents the entire overload set of functions of f
:
struct f_overload_set {
template<typename...As>
auto operator()(As&&...as)->
decltype(f(std::declval<As>()...))
{ return f(std::forward<As>(as)...); }
};
now pass f_overload_set{}
to your template
function.
template
s function value arguments must be values, and in current C++ there is no first class value that represents an entire overload set of a function. The symbol f
gets disambiguated into one overload at each point of use: but that requires an immediate context at the point of use. The above defers the disambiguation until we have the arguments handy.