How to infer return type of function returned from a function in c++
Consider this code template <typename OUT> auto fun(const int& x) { return [&](function<OUT(int)> fout) -> decltype(fout(x)) {return fout(x);}; } calling function auto w = fun(23)([](const auto& x) {return x*2;}); The function fun when called cannot deduce the return type as above code fails compilation with an error saying that "candidate template ignored: couldn’t infer template… Read More How to infer return type of function returned from a function in c++