# flow

## Header

    #include <boost/hof/flow.hpp>

## Description

The `flow` function adaptor provides function composition. It is useful as an alternative to using the pipe operator `|` when chaining functions. It is similiar to `compose` except the evaluation order is reversed. So, `flow(f, g)(0)` is equivalent to `g(f(0))`.

## Synopsis

    template<class... Fs>
    constexpr flow_adaptor<Fs...> flow(Fs... fs);

## Semantics

    assert(flow(f, g)(xs...) == g(f(xs...)));

## Requirements

Fs must be:

- ConstInvocable

- MoveConstructible

## Example

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

    struct increment
    {
        template<class T>
        T operator()(T x) const
        {
            return x + 1;
        }
    };

    struct decrement
    {
        template<class T>
        T operator()(T x) const
        {
            return x - 1;
        }
    };

    int main() {
        int r = flow(increment(), decrement(), increment())(3);
        assert(r == 4);
    }

## References

- Function composition