return __tmp;
}
+ // from_address cannot be used with the coroutines promise type.
+ static coroutine_handle from_address(_Promise*) = delete;
+
_LIBCPP_ALWAYS_INLINE
static coroutine_handle from_promise(_Promise& __promise) _NOEXCEPT {
coroutine_handle __tmp;
struct MyFuture {
struct promise_type {
typedef coro::coroutine_handle<promise_type> HandleT;
- coro::suspend_always initial_suspend() { return sa; }
- coro::suspend_never final_suspend() { return sn; }
+ coro::suspend_never initial_suspend() { return sn; }
+ coro::suspend_always final_suspend() { return sa; }
coro::suspend_never yield_value(int) { return sn; }
MyFuture get_return_object() {
- MyFuture f(HandleT::from_address(this));
+ MyFuture f(HandleT::from_promise(*this));
return f;
}
void return_void() {}
MyFuture() : p() {}
MyFuture(HandleT h) : p(h) {}
-private:
coro::coroutine_handle<promise_type> p;
};
int main()
{
MyFuture f = test_coro();
+ while (!f.p.done())
+ f.p.resume();
+ f.p.destroy();
}