Why does not this work with lambdas? It only works when I assing lambda to std::function before calling the function I want. Doesn't work when I construct lambda in place or assign lambda to auto.
#include <functional>
template <typename R>
R foo (std::function<R()> fun)
{
puts(__PRETTY_FUNCTION__);
}
int main()
{
std::function<int()> lambda = []{ return 1; };
foo (lambda); // --> OK
foo ([]() -> int { return 1; } ); // --> ERROR
auto lambda2 = []{ return 1; };
foo (lambda2); // --> ERROR
}