Commit da20bc44 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

no coroutine_traits

Summary: Use of `std::coroutine_traits` and `std::experimental::coroutine_traits` can get awkward and we do not actually need the flexibility. Just define member type aliases `promise_type`.

Reviewed By: andriigrynenko

Differential Revision: D26706363

fbshipit-source-id: 0cdb59d542a64ff85d8a126003a014b7b6be3134
parent 27eb45f0
......@@ -87,6 +87,8 @@ using ExpectedErrorType =
// Details...
namespace expected_detail {
template <typename Value, typename Error>
struct Promise;
template <typename Value, typename Error>
struct PromiseReturn;
......@@ -821,6 +823,8 @@ class Expected final : expected_detail::ExpectedStorage<Value, Error> {
template <class U>
using rebind = Expected<U, Error>;
using promise_type = expected_detail::Promise<Value, Error>;
static_assert(
!std::is_reference<Value>::value,
"Expected may not be used with reference types");
......@@ -1393,14 +1397,4 @@ expected_detail::Awaitable<Value, Error>
return expected_detail::Awaitable<Value, Error>{std::move(o)};
}
} // namespace folly
// This makes folly::Expected<Value> useable as a coroutine return type...
namespace std {
namespace experimental {
template <typename Value, typename Error, typename... Args>
struct coroutine_traits<folly::Expected<Value, Error>, Args...> {
using promise_type = folly::expected_detail::Promise<Value, Error>;
};
} // namespace experimental
} // namespace std
#endif // FOLLY_HAS_COROUTINES
......@@ -76,6 +76,8 @@ class Optional;
namespace detail {
template <class Value>
struct OptionalPromise;
template <class Value>
struct OptionalPromiseReturn;
} // namespace detail
......@@ -101,6 +103,8 @@ class Optional {
public:
typedef Value value_type;
using promise_type = detail::OptionalPromise<Value>;
static_assert(
!std::is_reference<Value>::value,
"Optional may not be used with reference types");
......@@ -676,13 +680,4 @@ detail::OptionalAwaitable<Value>
}
} // namespace folly
// This makes folly::Optional<Value> useable as a coroutine return type..
namespace std {
namespace experimental {
template <typename Value, typename... Args>
struct coroutine_traits<folly::Optional<Value>, Args...> {
using promise_type = folly::detail::OptionalPromise<Value>;
};
} // namespace experimental
} // namespace std
#endif // FOLLY_HAS_COROUTINES
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