aboutsummaryrefslogtreecommitdiffstats
path: root/include/experimental/coroutine
diff options
context:
space:
mode:
Diffstat (limited to 'include/experimental/coroutine')
-rw-r--r--include/experimental/coroutine30
1 files changed, 27 insertions, 3 deletions
diff --git a/include/experimental/coroutine b/include/experimental/coroutine
index d2a03ae8a8c8..21c1ea566403 100644
--- a/include/experimental/coroutine
+++ b/include/experimental/coroutine
@@ -145,6 +145,19 @@ public:
return __tmp;
}
+ // FIXME: Should from_address(nullptr) be allowed?
+ _LIBCPP_ALWAYS_INLINE
+ static coroutine_handle from_address(nullptr_t) _NOEXCEPT {
+ return coroutine_handle(nullptr);
+ }
+
+ template <class _Tp, bool _CallIsValid = false>
+ static coroutine_handle from_address(_Tp*) {
+ static_assert(_CallIsValid,
+ "coroutine_handle<void>::from_address cannot be called with "
+ "non-void pointers");
+ }
+
private:
bool __is_suspended() const _NOEXCEPT {
// FIXME actually implement a check for if the coro is suspended.
@@ -218,11 +231,22 @@ public:
// FIXME: should from_address work with nullptr?
_LIBCPP_ALWAYS_INLINE
static coroutine_handle from_address(nullptr_t) _NOEXCEPT {
- return {};
+ return coroutine_handle(nullptr);
+ }
+
+ template <class _Tp, bool _CallIsValid = false>
+ static coroutine_handle from_address(_Tp*) {
+ static_assert(_CallIsValid,
+ "coroutine_handle<promise_type>::from_address cannot be called with "
+ "non-void pointers");
}
- // from_address cannot be used with the coroutines promise type.
- static coroutine_handle from_address(_Promise*) = delete;
+ template <bool _CallIsValid = false>
+ static coroutine_handle from_address(_Promise*) {
+ static_assert(_CallIsValid,
+ "coroutine_handle<promise_type>::from_address cannot be used with "
+ "pointers to the coroutine's promise type; use 'from_promise' instead");
+ }
_LIBCPP_ALWAYS_INLINE
static coroutine_handle from_promise(_Promise& __promise) _NOEXCEPT {