#pragma once #include "constant_integral.hip.hpp" template struct static_loop_n { template __host__ __device__ void operator()(F f) const { static_assert(NLoop > 1, "out-of-range"); f(Number{}); static_loop_n{}(f); } }; template <> struct static_loop_n<1> { template __host__ __device__ void operator()(F f) const { f(Number<0>{}); } }; template struct static_const_reduce_n { template __host__ __device__ constexpr auto operator()(F f, Reduce r) const { static_assert(NLoop > 1, "out-of-range"); constexpr auto a = f(Number{}); auto b = static_const_reduce_n{}(f, r); // cannot use constexpr here, weird return r(a, b); } }; template <> struct static_const_reduce_n<1> { template __host__ __device__ constexpr auto operator()(F f, Reduce) const { return f(Number<0>{}); } };