Skip to content

Instantly share code, notes, and snippets.

@LesleyLai
Last active February 4, 2022 04:16
Show Gist options
  • Save LesleyLai/ef1fc28d858fbfb43af4a3d51a6314a8 to your computer and use it in GitHub Desktop.
Save LesleyLai/ef1fc28d858fbfb43af4a3d51a6314a8 to your computer and use it in GitHub Desktop.
C++ currying implementation by Ben Deane
template <typename Callable, typename... Params>
auto curry(Callable f, Params... ps)
{
if constexpr (requires { f(ps...); }) {
return f(ps...);
} else {
return [f, ps...] (auto... qs)
{
return curry(f, ps..., qs...);
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment