repeat

Description

The repeat function decorator will repeatedly apply a function a given number of times.

Synopsis

template<class Integral>
constexpr repeat_adaptor<Integral> repeat(Integral);

Requirements

Integral must be:

  • Integral

Or:

  • IntegralConstant

Example

#include <fit.hpp>
#include <cassert>

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

int main() {
    auto increment_by_5 = fit::repeat(std::integral_constant<int, 5>())(increment());
    assert(increment_by_5(1) == 6);
}