#pragma once #include namespace y_combinator_details { template struct y_combinator_result { template explicit y_combinator_result(T &&fun_) : fun(std::forward(fun_)) {} template decltype(auto) operator()(Args &&...args) { return fun(std::ref(*this), std::forward(args)...); } private: Fun fun; }; } // namespace y_combinator_details template static inline decltype(auto) y_combinator(Fun &&fun) { return y_combinator_details::y_combinator_result>( std::forward(fun)); }