xieite::unroll()

Defined in fragment xieite:unroll
(header-only: <xieite/fn/unroll.hpp>)


Unrolls a constant-sized loop using std::integer_sequence utilities.
Passes the indices to a given functor as a NTTP pack.


Declarations

#0
template<std::integral auto n>
constexpr auto unroll(auto&& fn, auto&&... args)
XIEITE_ARROW(/* XIEITE_FWD(fn).template operator()<0, 1, 2, ..., n>(XIEITE_FWD(args)...) */)
Unrolls for some constant integer.

#1
template<typename... Ts>
constexpr auto unroll(auto&& fn, auto&&... args)
XIEITE_ARROW(xieite::unroll<sizeof...(Ts)>(XIEITE_FWD(fn), XIEITE_FWD(args)...))
Unrolls for the number of types passed.


Example

import xieite;

int main() {
	xieite::unroll<5>([]<int... i> {
		xieite::dump(i...);
	});
}
Output:
0 1 2 3 4
View in Compiler Explorer