partial

Description

The partial function adaptor allows partial application of the function. If the function can not be called with all the parameters, it will return another function. It will repeatedly do this until the function can finally be called. By default, partial captures all of its variables by value, just like bind. std::ref can be used to capture references instead.

Synopsis

template<class F>
constexpr partial_adaptor<F> partial(F f);

Semantics

assert(partial(f)(xs...)(ys...) == f(xs..., ys...));

Requirements

F must be:

Example

#include <fit.hpp>
#include <cassert>
using namespace fit;

struct sum
{
    template<class T, class U>
    T operator()(T x, U y) const
    {
        return x+y;
    }
};

int main() {
    assert(3 == partial(sum())(1)(2));
}