coroutines-ts
coroutines-ts copied to clipboard
Clarify whether get_return_object() result is stored with 'auto' or 'decltype(auto)' semantics
The current specification (N4680) wording for get_return_object()
in 8.4.4(5) simply just says that:
... the return value is produced by a call to
p.get_return_object()
This return-value can potentially be of a different type to the return-type of the coroutine function and so the return-value needs to be stored somewhere while the coroutine is started.
I'm assuming that the coroutine is translated to something (very roughly) like this:
R foo(ARGS... args)
{
coro_frame* f = new coro_frame(std::forward<ARGS>(args)...);
auto returnObject = f->promise.get_return_object();
std::experimental::coroutine_handle<decltype(f->promise)>::from_promise(f->promise).resume();
return returnObject; // possible implicit conversion to R here
}
However, I'm wondering what the semantics are when get_return_object()
returns a reference.
Is the referenced copied/moved into a new variable (auto
semantics) or is the reference itself stored as the returnObject (decltype(auto)
semantics)?
Can the wording of 8.4.4(5) be amended to clarify this?