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> ...@@ -496,10 +496,6 @@ template <typename Reference, typename Value>
inline constexpr bool is_async_generator_v<AsyncGenerator<Reference, Value>> = inline constexpr bool is_async_generator_v<AsyncGenerator<Reference, Value>> =
true; true;
template <typename T>
using enable_if_async_generator_t =
std::enable_if_t<detail::is_async_generator_v<T>, T>;
} // namespace detail } // namespace detail
// Helper for immediately invoking a lambda with captures that returns an // Helper for immediately invoking a lambda with captures that returns an
......
...@@ -19,9 +19,16 @@ ...@@ -19,9 +19,16 @@
namespace folly { namespace folly {
namespace coro { namespace coro {
template <typename Head, typename... Tail> template <
detail::enable_if_async_generator_t<Head> concat(Head head, Tail... tail) { typename HReference,
using list = Head[]; 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)...}) { for (auto& gen : list{std::move(head), std::move(tail)...}) {
while (auto val = co_await gen.next()) { while (auto val = co_await gen.next()) {
co_yield std::move(val).value(); co_yield std::move(val).value();
......
...@@ -42,8 +42,14 @@ namespace coro { ...@@ -42,8 +42,14 @@ namespace coro {
// //
// return result; // return result;
// } // }
template <typename Head, typename... Tail> template <
detail::enable_if_async_generator_t<Head> concat(Head head, Tail... tail); typename HReference,
typename... TReference,
typename HValue,
typename... TValue>
AsyncGenerator<HReference, HValue> concat(
AsyncGenerator<HReference, HValue> head,
AsyncGenerator<TReference, TValue>... tail);
} // namespace coro } // namespace coro
} // namespace folly } // 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