cuda::experimental::stf::each_in_pack

Defined in include/cuda/experimental/__stf/utility/core.cuh

template<typename F, typename ...P>
constexpr void cuda::experimental::stf::each_in_pack(F &&f, P&&... p)

Applies a given function to each element in a parameter pack.

If the callable object f accepts two parameters, each_in_pack calls f(std::integral_constant<size_t, i>(), std::forward<P>(p)) for each p at position i in the parameter pack. Otherwise, each_in_pack calls f(std::forward<P>(p)) for each p in the parameter pack.

std::string s;
cuda::experimental::stf::each_in_pack([&](auto&& p) { s += std::to_string(p) + ", "; }, 1, 2, 3, 4, 5);
assert(s == "1, 2, 3, 4, 5, ");
s = "";
cuda::experimental::stf::each_in_pack([&](auto i, auto&& p) { s += (i ? ", " : "") + std::to_string(i) + p; }, "a",
"b", "c"); assert(s == "0a, 1b, 2c"); 

Template Parameters
  • F – Callable object type

  • P – Variadic template parameter pack type

Parameters
  • f – Callable object to apply to each element in the parameter pack

  • p – Variadic parameter pack