Title
connect-awaitable should use `is_void_v` to check for result-type of `co_await` expression instead of same_as<void>
Status
new
Section
[exec.connect]
Submitter
Lewis Baker

Created on 2025-08-27.00:00:00 last changed 4 days ago

Messages

Date: 2025-09-14.11:21:22

Proposed resolution:

This wording is relative to N5014.

  1. Modify [exec.connect] as indicated:

    -5- Let `V` name the type await-result-type<DS, connect-awaitable-promise>, let `Sigs` name the type

    completion_signatures<
      SET-VALUE-SIG(V), // see [exec.snd.concepts]
      set_error_t(exception_ptr),
      set_stopped_t()>
    

    and let connect-awaitable be an exposition-only coroutine defined as follows:

    namespace std::execution {
      […]
      operation-state-task connect-awaitable(DS sndr, DR rcvr) requires receiver_of<DR, Sigs> {
        exception_ptr ep;
        try {
          if constexpr (same_as<V, void>is_void_v<V>) {
            co_await std::move(sndr);
            co_await suspend-complete(set_value, std::move(rcvr));
          } else {
            co_await suspend-complete(set_value, std::move(rcvr), co_await std::move(sndr));
          }
        } catch(...) {
          ep = current_exception();
        }
        co_await suspend-complete(set_error, std::move(rcvr), std::move(ep));
      }
    }  
    
Date: 2025-08-27.00:00:00

The wording in [exec.connect] p5 defines the connect-awaitable() function as follows:

operation-state-task connect-awaitable(DS sndr, DR rcvr) requires receiver_of<DR, Sigs> {
  exception_ptr ep;
  try {
    if constexpr (same_as<V, void>) {
      co_await std::move(sndr);
      co_await suspend-complete(set_value, std::move(rcvr));
    } else {
      co_await suspend-complete(set_value, std::move(rcvr), co_await std::move(sndr));
    }
  } catch(...) {
    ep = current_exception();
  }
  co_await suspend-complete(set_error, std::move(rcvr), std::move(ep));
}

The use of same_as<V, void> in the if-constexpr condition does not cover the case where the result of the `co_await` expression has type cv `void`. It should use is_void_v<V> instead to allow it to match all `void` types, not just unqualified `void`.

History
Date User Action Args
2025-09-14 11:21:22adminsetmessages: + msg15030
2025-08-27 00:00:00admincreate