| 65 | // It is not travial to implement an asynchronous do_for_each. |
| 66 | template <typename InputIt, typename Callable> |
| 67 | Future<void> do_for_each(InputIt Begin, InputIt End, Callable func) { |
| 68 | for (auto It = Begin; It != End; ++It) { |
| 69 | auto F = std::invoke(func, *It); |
| 70 | // If we met an error, return early. |
| 71 | if (F.result().hasError()) |
| 72 | return F; |
| 73 | if (F.hasResult()) |
| 74 | continue; |
| 75 | return std::move(F).thenTry( |
| 76 | [SubBegin = ++It, SubEnd = End, func](auto &&) { |
| 77 | return do_for_each(SubBegin, SubEnd, func); |
| 78 | }); |
| 79 | } |
| 80 | return makeReadyFuture(); |
| 81 | } |
| 82 | |
| 83 | template <Range RangeTy, typename Callable> |
| 84 | Future<void> do_for_each(const RangeTy &Rng, Callable func) { |
no test coverage detected