diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/experimental/coroutine | 30 | ||||
| -rw-r--r-- | include/module.modulemap | 1 |
2 files changed, 28 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 { diff --git a/include/module.modulemap b/include/module.modulemap index 462d4234ae6c..98b1870afcc1 100644 --- a/include/module.modulemap +++ b/include/module.modulemap @@ -502,6 +502,7 @@ module std [system] { export * } module coroutine { + requires coroutines header "experimental/coroutine" export * } |
