Shortcuts

Template Function ripple::unrolled_for

Function Documentation

template<size_t Amount, typename Functor, typename ...Args>
constexpr auto ripple::unrolled_for(Functor &&functor, Args&&... args) noexcept -> void

Applies the functor Amount times and passes the index of the unrolling as the first argument to the functor.

The unrolling is performed at compile time, so the number of iterations should not be too large, otherwise this will cause code bloat.

The index parameter has a compile-time value, and can therefore be used in constexpr contexts. For example:

auto tuple = std::make_tuple("string", 4, AType*());
unrolled_for<2>([&tuple] (auto i) {
  do_something(get<i>(tuple), get<i + 1>(tuple));
});

Which effectively will become:

do_something(get<0>(tuple), get<1>(tuple));
do_something(get<1>(tuple), get<2>(tuple));

Note

If it’s required that the unrolling is bounded, then use the unrolled_for_bounded.

Parameters
  • functor: The functor to unroll.

  • args: The arguments to the functor.

Template Parameters
  • Amount: The amount of unrolling to do.

  • Functor: The type of the functor.

  • Args: The type of the functor arguments.

Docs

Access comprehensive developer documentation for Ripple

View Docs

Tutorials

Get tutorials to help with understand all features

View Tutorials

Examples

Find examples to help get started

View Examples