execution__connect.html 6.52 KB
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>execution::connect</title>
<link rel="stylesheet" href="../../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../index.html" title="Asio">
<link rel="up" href="../reference.html" title="Reference">
<link rel="prev" href="execution__can_submit.html" title="execution::can_submit">
<link rel="next" href="execution__connect_result.html" title="execution::connect_result">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="asio C++ library" width="250" height="60" src="../../asio.png"></td></tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="execution__can_submit.html"><img src="../../prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../home.png" alt="Home"></a><a accesskey="n" href="execution__connect_result.html"><img src="../../next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="asio.reference.execution__connect"></a><a class="link" href="execution__connect.html" title="execution::connect">execution::connect</a>
</h3></div></div></div>
<p>
        <a class="indexterm" name="asio.indexterm.execution__connect"></a> 
A customisation point
        that connects a sender to a receiver.
      </p>
<pre class="programlisting">constexpr unspecified connect = unspecified;
</pre>
<p>
        The name <code class="computeroutput">execution::connect</code> denotes a customisation point object.
        For some subexpressions <code class="computeroutput">s</code> and <code class="computeroutput">r</code>, let <code class="computeroutput">S</code>
        be a type such that <code class="computeroutput">decltype((s))</code> is <code class="computeroutput">S</code> and let
        <code class="computeroutput">R</code> be a type such that <code class="computeroutput">decltype((r))</code> is <code class="computeroutput">R</code>.
        The expression <code class="computeroutput">execution::connect(s, r)</code> is expression-equivalent
        to:
      </p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
            <code class="computeroutput">s.connect(r)</code>, if that expression is valid, if its type satisfies
            <code class="computeroutput">operation_state</code>, and if <code class="computeroutput">S</code> satisfies <code class="computeroutput">sender</code>.
          </li>
<li class="listitem">
            Otherwise, <code class="computeroutput">connect(s, r)</code>, if that expression is valid, if
            its type satisfies <code class="computeroutput">operation_state</code>, and if <code class="computeroutput">S</code>
            satisfies <code class="computeroutput">sender</code>, with overload resolution performed in
            a context that includes the declaration <code class="computeroutput">void connect();</code>
            and that does not include a declaration of <code class="computeroutput">execution::connect</code>.
          </li>
<li class="listitem">
            Otherwise, <code class="computeroutput">as_operation{s, r}</code>, if <code class="computeroutput">r</code> is not
            an instance of <code class="computeroutput">as_receiver&lt;F, S&gt;</code> for some type <code class="computeroutput">F</code>,
            and if <code class="computeroutput">receiver_of&lt;R&gt; &amp;&amp; executor_of&lt;remove_cvref_t&lt;S&gt;,
            as_invocable&lt;remove_cvref_t&lt;R&gt;, S&gt;&gt;</code> is <code class="computeroutput">true</code>,
            where <code class="computeroutput">as_operation</code> is an implementation-defined class equivalent
            to
          </li>
</ul></div>
<pre class="programlisting">template &lt;class S, class R&gt;
 struct as_operation
 {
   remove_cvref_t&lt;S&gt; e_;
   remove_cvref_t&lt;R&gt; r_;
   void start() noexcept try {
     execution::execute(std::move(e_),
         as_invocable&lt;remove_cvref_t&lt;R&gt;, S&gt;{r_});
   } catch(...) {
     execution::set_error(std::move(r_), current_exception());
   }
 };
</pre>
<p>
        and <code class="computeroutput">as_invocable</code> is a class template equivalent to the following:
      </p>
<pre class="programlisting">template&lt;class R&gt;
 struct as_invocable
 {
   R* r_;
   explicit as_invocable(R&amp; r) noexcept
     : r_(std::addressof(r)) {}
   as_invocable(as_invocable &amp;&amp; other) noexcept
     : r_(std::exchange(other.r_, nullptr)) {}
   ~as_invocable() {
     if(r_)
       execution::set_done(std::move(*r_));
   }
   void operator()() &amp; noexcept try {
     execution::set_value(std::move(*r_));
     r_ = nullptr;
   } catch(...) {
     execution::set_error(std::move(*r_), current_exception());
     r_ = nullptr;
   }
 };
</pre>
<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
            Otherwise, <code class="computeroutput">execution::connect(s, r)</code> is ill-formed.
          </li></ul></div>
<h5>
<a name="asio.reference.execution__connect.h0"></a>
        <span><a name="asio.reference.execution__connect.requirements"></a></span><a class="link" href="execution__connect.html#asio.reference.execution__connect.requirements">Requirements</a>
      </h5>
<p>
        <span class="emphasis"><em>Header: </em></span><code class="literal">asio/execution/connect.hpp</code>
      </p>
<p>
        <span class="emphasis"><em>Convenience header: </em></span><code class="literal">asio/execution.hpp</code>
      </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M.
      Kohlhoff<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="execution__can_submit.html"><img src="../../prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../home.png" alt="Home"></a><a accesskey="n" href="execution__connect_result.html"><img src="../../next.png" alt="Next"></a>
</div>
</body>
</html>