Suppose I have a higher order variational function
template<typename F, typename ...Args>
void execution(F func, Args&&... args)
{
func(std::forward<Args>(args)...);
}
Then for this overload set
void f() {}
void f(int arg) {}
Overload resolution will not be possible
int main()
{
execution(f, 1);
execution(f);
return 0;
}
However, if only one of the two is provided, the program compiles
- Why is this happening? Why does the template argument fail?
If I remove f()from the set and replace it with f(arg, arg2), the problem. Is there a workaround, or I should always provide the type of function as the template argument?
execution<void()>(f);
source
share