#pragma once #include "functional.hip.hpp" #include "Sequence.hip.hpp" #if 0 template struct static_for_impl { template constexpr __host__ __device__ void operator()(F f) const { static_assert(Remaining % Increment == 0, "wrong! Remaining % Increment != 0"); static_assert(Increment <= Remaining, "will go out-of-range"); f(Number{}); static_for_impl{}(f); } }; template struct static_for_impl { template constexpr __host__ __device__ void operator()(F) const { // no work left, just return return; } }; // F signature: F(Number) template struct static_for { template constexpr __host__ __device__ void operator()(F f) const { static_assert(NBegin <= NEnd, "wrongs! should have NBegin <= NEnd"); static_assert((NEnd - NBegin) % Increment == 0, "Wrong! should satisfy (NEnd - NBegin) % Increment == 0"); #if 0 static_if<(NBegin < NEnd)>{}( [&](auto fwd) { static_for_impl{}(f); }); #else static_for_impl{}(f); #endif } }; #else template struct static_for_impl; template struct static_for_impl> { template __host__ __device__ constexpr void operator()(F f) const { swallow{(f(Number{}), 0)...}; } }; // F signature: F(Number) template struct static_for { template __host__ __device__ constexpr void operator()(F f) const { static_assert(NBegin <= NEnd, "wrongs! should have NBegin <= NEnd"); static_assert((NEnd - NBegin) % Increment == 0, "Wrong! should satisfy (NEnd - NBegin) % Increment == 0"); static_for_impl::SeqType>{}(f); } }; #endif