return type deduction of recursive function
问题 Recently, I read Barry's answer to this question Recursive lambda functions in C++11: template <class F> struct y_combinator { F f; // the lambda will be stored here // a forwarding operator(): template <class... Args> decltype(auto) operator()(Args&&... args) const { // we pass ourselves to f, then the arguments. // [edit: Barry] pass in std::ref(*this) instead of *this return f(std::ref(*this), std::forward<Args>(args)...); } }; // deduction guide template <class F> y_combinator(F) -> y