cplusplus / sender-receiver

Issues list for P2300
Apache License 2.0
20 stars 4 forks source link

noexcept clause of `basic-state` constructor is incomplete #279

Open lewissbaker opened 4 months ago

lewissbaker commented 4 months ago

In P2300R10 [exec.snd.general] p3.14.6 it describes the noexcept clause expression for the basic-state constructor as:

is_nothrow_move_constructible_v<Rcvr> &&
nothrow-callable<decltype(impls-for<tag_of_t<Sndr>>::get-state), Sndr, Rcvr&>

However, this doesn't take into account the fact that the return-type of get-state might return a reference which is used to initialize a data-member of the decayed-returne type of get-state.

The state member of basic-state has type state-type<Sndr, Rcvr> which is defined as:

  template<class Sndr, class Rcvr> // exposition only
  using state-type = decay_t<call-result-t<
    decltype(impls-for<tag_of_t<Sndr>>::get-state), Sndr, Rcvr&>>;

Therefore, the noexcept expression needs to take into account that Sndr might be a const-ref and that get-state therefore returns a const-ref (the default impl returns a reference to the data member of the Sndr object) and therefore needs to make a copy.

i.e. should be changed to something like:

is_nothrow_move_constructible_v<Rcvr> &&
nothrow-callable<decltype(impls-for<tag_of_t<Sndr>>::get-state), Sndr, Rcvr&> &&
is_nothrow_constructible_v<state-type<Sndr, Rcvr>,
                           call-result-t<decltype(impls-for<tag_of_t<Sndr>>::get-state), Sndr, Rcvr&>>>
lewissbaker commented 1 month ago

A resolution to this issue has been proposed in https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3396r0.html