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.

4337. co_await change_coroutine_scheduler(s) requires assignable

Section: 33.13.6.5 [task.promise] Status: New Submitter: Dietmar Kühl Opened: 2025-08-31 Last modified: 2025-09-01

Priority: Not Prioritized

View other active issues in [task.promise].

View all other issues in [task.promise].

View all issues with New status.

Discussion:

The specification of change_coroutine_scheduler(sched) uses std::exchange to put the scheduler into place (in 33.13.6.5 [task.promise] paragraph 11). The problem is that std::exchange(x, v) expects x to be assignable from v but there is no requirement for scheduler to be assignable.

Proposed resolution:

Change the wording in 33.13.6.5 [task.promise] paragraph 11 to avoid the use of std::exchange and transfer the using construction:

template<class Sch>
  auto await_transform(change_coroutine_scheduler<Sch> sch) noexcept;

-11- Effects: Equivalent to:

return await_transform(just(exchange(SCHED(*this), scheduler_type(sch.scheduler))), *this);
auto* s{address_of(SCHED(*this))};
auto rc{std::move(*s)};
s->~scheduler_type();
new(s) scheduler_type(std::move(sch));
return std::move(rc);