Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

Equivalent [1] C++14 for comparison:

   template<class F, class A>
   auto apply(F f, A a) {
      return [f=std::move(f), a=std::move(a)](auto&& b) {
        return f(std::forward<dectlype(b)>(b))(a);
      }
   }
The forward<decltype> is an abomination and is really in need of a language based solution, but otherwise is fairly straightforward.

[1] No type checking of the definition of course, only of instantiations. On the plus side, the returned function is polymorphic and can be called for all Bs that f can be called.



Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: