Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.


A customisation point that connects a sender to a receiver.

constexpr unspecified connect = unspecified;

The name execution::connect denotes a customisation point object. For some subexpressions s and r, let S be a type such that decltype((s)) is S and let R be a type such that decltype((r)) is R. The expression execution::connect(s, r) is expression-equivalent to:

template <class S, class R>
 struct as_operation
   remove_cvref_t<S> e_;
   remove_cvref_t<R> r_;
   void start() noexcept try {
         as_invocable<remove_cvref_t<R>, S>{r_});
   } catch(...) {
     execution::set_error(std::move(r_), current_exception());

and as_invocable is a class template equivalent to the following:

template<class R>
 struct as_invocable
   R* r_;
   explicit as_invocable(R& r) noexcept
     : r_(std::addressof(r)) {}
   as_invocable(as_invocable && other) noexcept
     : r_(std::exchange(other.r_, nullptr)) {}
   ~as_invocable() {
   void operator()() & noexcept try {
     r_ = nullptr;
   } catch(...) {
     execution::set_error(std::move(*r_), current_exception());
     r_ = nullptr;

Header: boost/asio/execution/connect.hpp

Convenience header: boost/asio/execution.hpp