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.
connect() should use get_allocator(get_env(rcvr)) to allocate the coroutine-state for a
connect-awaitable coroutineSection: 33.9.10 [exec.connect] Status: New Submitter: Lewis Baker Opened: 2025-08-27 Last modified: 2025-10-23
Priority: 2
View other active issues in [exec.connect].
View all other issues in [exec.connect].
View all issues with New status.
Discussion:
The wording for connect() (33.9.10 [exec.connect]) handles passing awaitable types as the sender argument
by calling the connect-awaitable() coroutine and having it execute a co_await expression.
connect-awaitable() coroutine will typically need to dynamically allocate storage for
the coroutine state and, as specified, this currently just always uses the global default allocator.
This is because the connect-awaitable-promise type does not define any member operator
new/delete overloads.
It seems desirable for this facility to use the allocator obtained from the receiver, by calling
get_allocator(get_env(rcvr)), in order to allocate storage for the coroutine-state instead of always
using global operator new. This would give the user at least some level of control over how this
allocation is performed.
[2025-10-23; Reflector poll.]
Set priority to 2 after reflector poll.
"The get_allocator query doesn't have a default and I think that isn't
covered in the proposed resolution."
Proposed resolution:
This wording is relative to N5014.
Modify 33.9.10 [exec.connect] as indicated:
[Drafting note: This should cover the design intent, although we may want to spell this out more explicitly in terms of the exact semantics in a similar way to 25.8.5 [coro.generator.promise] p17, which lists overloads of operator
new()and describes the rebound allocator type which allocates storage in chunks of size__STDCPP_DEFAULT_NEW_ALIGNMENT__.]
-5- Let
Vname the typeawait-result-type<DS, connect-awaitable-promise>, letSigsname the type[…]and let
connect-awaitablebe an exposition-only coroutine defined as follows:namespace std::execution { […] }Any dynamically allocated storage required for the coroutine state allocated by an invocation of the form
-6- […]connect-awaitable(sndr, rcvr)is allocated using the allocator obtained fromget_allocator(get_env(rcvr)).