cuda::experimental::stf::make_tuple_indexwise#
-
template<size_t n, typename F, size_t... i>
constexpr auto cuda::experimental::stf::make_tuple_indexwise(
)# Creates a
std::tupleby applying a callable objectfto each integral constant within a given range[0, n).This function template takes a callable object
fand applies it to each integral constant in the range[0, n). The results of the calls are collected into astd::tupleand returned. The callable object is expected to take a single argument of typestd::integral_constant<size_t, i>, whereiis the current index, and return a value of the desired type and value.If
freturnsstd::ignorefor any argument(s), the corresponding value(s) will be skipped in the resulting tuple.Example usage:
auto make_double = [](auto index) { if constexpr (index == 2) return std::ignore; else return static_cast<double>(index); }; auto result = make_tuple_indexwise<5>(make_double); // result is std::tuple<double, double, double, double>{0.0, 1.0, 3.0, 4.0}
Note: Since this function is
constexpr, it can be used at compile-time iffis a compile-time invocable object.- Template Parameters:
n – The number of times the callable object
fshould be applied.F – Type of the callable object.
i... – (Internal) Indices for parameter pack expansion.
- Parameters:
f – The callable object to apply to each integral constant.
- Returns:
A
std::tuplecontaining the results of applyingfto each integral constant in the range[0, n).