partial — Boost.HigherOrderFunctions 0.6 documentation

# partial

## Header

    #include <boost/hof/partial.hpp>

## 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. As such all parameters must be `MoveConstructible` when the function is aprtial application. `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:

- ConstInvocable
- MoveConstructible

## Example

    #include <boost/hof.hpp>
    #include <cassert>
    using namespace boost::hof;

    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));
    }

## References

- Partial application
- Currying