13 #include <hipipe/core/stream/template_arguments.hpp>
14 #include <hipipe/core/stream/transform.hpp>
15 #include <hipipe/core/utility/tuple.hpp>
17 namespace hipipe::stream {
23 template<
typename Fun,
typename... FromTypes>
24 struct wrap_void_fun_for_transform {
27 utility::maybe_tuple<FromTypes...> operator()(FromTypes&... args)
29 static_assert(std::is_invocable_v<Fun, FromTypes&...>,
30 "hipipe::stream::for_each: "
31 "Cannot apply the given function to the given `from<>` columns.");
32 std::invoke(fun, args...);
35 return {std::move(args)...};
61 template<
typename... FromColumns,
typename Fun,
int Dim = 1>
62 auto for_each(from_t<FromColumns...> f, Fun fun, dim_t<Dim> d = dim_t<1>{})
65 ((utility::ndims<typename FromColumns::data_type>::value >= Dim) && ...),
66 "hipipe::stream::for_each: The dimension in which to apply the operation "
67 " needs to be at most the lowest dimension of all the from<> columns.");
69 using FunT = std::function<
70 void(utility::ndim_type_t<typename FromColumns::data_type, Dim>&...)>;
72 detail::wrap_void_fun_for_transform<
73 FunT, utility::ndim_type_t<typename FromColumns::data_type, Dim>...>
74 fun_wrapper{std::move(fun)};