I'm wondering why in the following code the compiler is unable to use lambda as the argument for function foo() (template argument deduction/substitution failed), while a simple function works:
template<class ...Args>
void foo(int (*)(Args...))
{
}
int bar(int)
{
return 0;
}
int main() {
//foo([](int) { return 0; }); // error
foo(bar);
return 0;
}
The intel compiler (version 18.0.3 )
template.cxx(12): error: no instance of function template "foo" matches the argument list
argument types are: (lambda [](int)->int)
foo([](int) { return 0; }); // error
^
template.cxx(2): note: this candidate was rejected because at least one template argument could not be deduced
void foo(int (*)(Args...))
Any ideas?