zero-overhead C++17 currying & partial application—Vittorio Romeo

Save to:
Instapaper Pocket Readability

This article briefly explains the concepts of "currying" and "partial application", then covers the design and C++17 implementation of a generic zero-overheader constexpr `curry` function.

zero-overhead C++17 currying & partial application

by Vittorio Romeo

From the article:

[...] many features introduced in the latest C++ standards allow functional patterns to thrive in your codebase, [...] like currying and partial application. [...] In this article we're going to:

* Introduce and briefly explain the two aforementioned concepts.

* Write a generic constexpr zero-overhead `curry` function in C++17.

* Analyze the generated assembly of the implementation to prove the lack of overhead.

[...]

Given a generic function object `f`, invoking `curry(f)` will return a curried/partially-applicable version of `f`. If `f` is constexpr-friendly, the returned one will be as well. `curry` should not introduce any overhead compared to hand-written currying/partial application.

Add a Comment

You must sign in or register to add a comment.

Comments (0)

There are currently no comments on this entry.