This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
Section: 33.13.1 [exec.as.awaitable] Status: New Submitter: Lewis Baker Opened: 2025-08-27 Last modified: 2025-09-14
Priority: Not Prioritized
View other active issues in [exec.as.awaitable].
View all other issues in [exec.as.awaitable].
View all issues with New status.
Discussion:
In 33.13.1 [exec.as.awaitable] bullet 7.2 it states:
(7.2) — Otherwise,
Preconditions:(void(p), expr)
ifis-awaitable<Expr, U>
istrue
, whereU
is an unspecified class type that is notPromise
and that lacks a member namedawait_transform
.is-awaitable<Expr, Promise>
istrue
and the expressionco_await expr
in a coroutine with promise typeU
is expression-equivalent to the same expression in a coroutine with promise typePromise
.
The "Preconditions:" sentence there refers to static properties of the program and so seems like a better fit for a Mandates: element or for folding into the constraint.
Also, in the part of the precondition above which says "… and the expressionco_await expr
in a
coroutine with promise type U
is expression-equivalent to the same expression in a coroutine with promise
type Promise
" it is unclear how this can be satisfied, as the types involved are different and therefore
the expression cannot be expression-equivalent.
I think perhaps what is intended here is something along the lines of the first expression having
"effects equivalent to" the second expression, instead of "expression-equivalent to"?
However, I think there is a more direct way to express the intent here, by instead just requiring that
decltype(GET-AWAITER(expr))
satisfies is-awaiter<Promise>
.
This checks whether expr
would be a valid type to return from a Promise::await_transform()
function.
Proposed resolution:
This wording is relative to N5014.
Modify 33.13.1 [exec.as.awaitable] as indicated:
-7-
as_awaitable
is a customization point object. For subexpressionsexpr
andp
wherep
is an lvalue,Expr
names the typedecltype((expr))
andPromise
names the typedecay_t<decltype((p))>
,as_awaitable(expr, p)
is expression-equivalent to, except that the evaluations ofexpr
andp
are indeterminately sequenced:
(7.1) —
Mandates:expr.as_awaitable(p)
if that expression is well-formed.is-awaitable<A, Promise>
istrue
, whereA
is the type of the expression above.(7.2) — Otherwise,
(void(p), expr)
ifdecltype(GET-AWAITER(expr))
satisfiesis-awaiter<Promise>
.is-awaitable<Expr, U>
istrue
, whereU
is an unspecified class type that is notPromise
and that lacks a member namedawait_transform
.Preconditions:is-awaitable<Expr, Promise>
istrue
and the expressionco_await expr
in a coroutine with promise typeU
is expression-equivalent to the same expression in a coroutine with promise typePromise
.(7.3) — […]
(7.4) — […]
(7.5) — […]