59 DiAction_
const& di_action,
70 typename ActionReturnType::value_type,
86 auto maybe_args = [di_action, &context]<
typename... ActionDependencies>(
89 auto args_preparations = [di_action, &context]<std::size_t... Idx>(std::index_sequence<Idx...>) {
93 [di_action]() -> std::optional<tag_t> {
94 auto it = std::ranges::find_if(
95 di_action.dependency_tags,
96 [](
const auto& tag_pair){
97 return tag_pair.first == Idx;
101 if (it == std::ranges::end(di_action.dependency_tags)) [[unlikely]]
110 }(std::index_sequence_for<ActionDependencies...>{});
112 return std::apply([](
auto&&... preparations) {
113 using TupleResult = std::tuple<ActionDependencies...>;
115 if ((preparations.has_value() && ...))
117 return std::expected<TupleResult, Error> {
118 std::tuple { std::move(preparations.value())... }
122 return std::expected<TupleResult, Error> {
125 }, std::move(args_preparations));
126 }(ActionDependenciesPack{});
128 if (!maybe_args.has_value()) [[unlikely]]
130 return ResultType { std::unexpected {
135 auto& args = maybe_args.value();
139 ActionReturnType action_result
140 = std::apply(di_action.action, args);
142 if (!action_result.has_value()) [[unlikely]]
144 return ResultType { std::unexpected {
149 return ResultType { action_result.value() };
151 else if constexpr (std::is_void_v<ActionReturnType>)
153 std::apply(di_action.action, args);
154 return ResultType {};
158 ActionReturnType action_result
159 = std::apply(di_action.action, args);
161 return ResultType { action_result };