Concatenate the values from multiple streams into a single stream such that each stream is exhausted before the next one begins.
Declared in <folly/coro/Concat.h>
template<
typename HReference,
typename... TReference,
typename HValue,
typename... TValue>
AsyncGenerator<HReference, HValue>
concat(
AsyncGenerator<HReference, HValue> head,
AsyncGenerator<TReference, TValue>... tail);
The input is a variadic list of AsyncGenerators, where each input has the same Reference and Value types.
The output is a single AsyncGenerator over all of the input generators.
Example: AsyncGenerator<int> stream();
Task<int> consumer() { auto values = concat(stream(), stream(), stream());
int result = 0; while (auto item = co_await values.next()) { result += *item; }
return result; }
A single generator yielding the values of every input generator.
| Name | Description |
|---|---|
| head | The first generator to consume. |
| tail | The remaining generators, consumed in order after head. |