Skip to content

alias template connect_result_t should be constrained with sender_to #320

Open
@ericniebler

Description

@ericniebler

since turning execution::connect(sndr, rcvr)'s constraints to a mandates, the connect customization point is now unconstrained.

but there is at least one place in the algorithms ([exec.let]) that is using connect_result_t in an immediate context of a function template with the expectation that connect_result_t<Sndr, Rcvr> will be well-formed only when Sndr and Rcvr can actually be connected. with the current definition, connect_result_t<Sndr, Rcvr> could very well cause a hard error; it will never cuase a substitution failure.

the solution is to constrain the connect_result_t alias template. just as completion_signatures_of_t<Sndr, Env> is constrained with sender_in<Sndr, Env>, so too should connect_result_t<Sndr, Rcvr> be constrained with sender_to<Sndr, Rcvr>.

for reference, the sender_to concept is defined as follows:

template<class Sndr, class Rcvr>
    concept sender_to =
      sender_in<Sndr, env_of_t<Rcvr>> &&
      receiver_of<Rcvr, completion_signatures_of_t<Sndr, env_of_t<Rcvr>>> &&
      requires (Sndr&& sndr, Rcvr&& rcvr) {
        connect(std::forward<Sndr>(sndr), std::forward<Rcvr>(rcvr));
      };

Proposed resolution

Change [exec.syn] as follows:

  template<class Sndr, class Rcvr>
+     requires sender_to<Sndr, Rcvr>
    using connect_result_t =
      decltype(connect(declval<Sndr>(), declval<Rcvr>()));

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1bugSomething isn't workingpending-wg21A paper or an LWG issue exits

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions