C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Relaxing coroutine return_value/return_void restrictions

From: Ted Lyngmo <ted_at_[hidden]>
Date: Thu, 11 Sep 2025 21:44:27 +0200
2025-09-11 13:21, Avi Kivity via Std-Proposals:
> The Standard says
> >
> > If searches for the names return_void and return_value in the scope
> > of the promise type each find any declarations, the program is ill-
> > formed.
>
> However, there are cases where one wants both "co_return;" and
> co_return something;" statements in the same coroutine.
>
> The cases are when the coroutine returns a sum type such as std::future
> or std::expected, and one of the options is void (e.g.
> std::future<void> or std::expected<void, something>. In these cases,
> one would want

Do you mean that you want it selectable at runtime depending on if the
`std::expected` contains the expected, void, or `something´? How would
that look in an example (that is accepted by an earlier version of gcc)?
A working example at godbolt would be nice to see it in action.

Otherwise, isn't that what _constexpr-if_ solves?

Best regards,
Ted Lyngmo

Received on 2025-09-11 19:44:32