Commit 22d18f0b authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

More direct overload resolution control in folly::coro::concat

Summary: [Folly] More direct overload resolution control in `folly::coro::concat`. Just name the type directly rather than using SFINAE, when the SFINAE would just name the type directly in a more roundabout way.

Differential Revision: D18746633

fbshipit-source-id: 6da909834b511426b1cf7bbda0fd7643b5761f14
parent b1211e4c
......@@ -496,10 +496,6 @@ template <typename Reference, typename Value>
inline constexpr bool is_async_generator_v<AsyncGenerator<Reference, Value>> =
true;
template <typename T>
using enable_if_async_generator_t =
std::enable_if_t<detail::is_async_generator_v<T>, T>;
} // namespace detail
// Helper for immediately invoking a lambda with captures that returns an
......
......@@ -19,9 +19,16 @@
namespace folly {
namespace coro {
template <typename Head, typename... Tail>
detail::enable_if_async_generator_t<Head> concat(Head head, Tail... tail) {
using list = Head[];
template <
typename HReference,
typename... TReference,
typename HValue,
typename... TValue>
AsyncGenerator<HReference, HValue> concat(
AsyncGenerator<HReference, HValue> head,
AsyncGenerator<TReference, TValue>... tail) {
static_assert((std::is_same_v<decltype(head), decltype(tail)> && ...));
using list = AsyncGenerator<HReference, HValue>[];
for (auto& gen : list{std::move(head), std::move(tail)...}) {
while (auto val = co_await gen.next()) {
co_yield std::move(val).value();
......
......@@ -42,8 +42,14 @@ namespace coro {
//
// return result;
// }
template <typename Head, typename... Tail>
detail::enable_if_async_generator_t<Head> concat(Head head, Tail... tail);
template <
typename HReference,
typename... TReference,
typename HValue,
typename... TValue>
AsyncGenerator<HReference, HValue> concat(
AsyncGenerator<HReference, HValue> head,
AsyncGenerator<TReference, TValue>... tail);
} // namespace coro
} // namespace folly
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment