New async_result with two template parameters.

This change makes async_result consistent with the networking TS.

The older single-parameter form of async_result, and the handler_type
trait, have been deprecated. They have been retained for backwards
compatibility, and existing specialisations of these traits will still
be used. However, asynchronous operations that use the older form of
async_result/handler_type will not interoperate with completion tokens
that specialize only the new two-parameter async_result. For this
reason, the completion token types implemented by asio continue to
provide specialisations of the older form of async_result and
handler_type.
diff --git a/asio/include/asio/async_result.hpp b/asio/include/asio/async_result.hpp
index 12ccd1e..7d2041f 100644
--- a/asio/include/asio/async_result.hpp
+++ b/asio/include/asio/async_result.hpp
@@ -25,10 +25,93 @@
 
 /// An interface for customising the behaviour of an initiating function.
 /**
+ * The async_result traits class is used for determining:
+ *
+ * @li the concrete completion handler type to be called at the end of the
+ * asynchronous operation;
+ *
+ * @li the initiating function return type; and
+ *
+ * @li how the return value of the initiating function is obtained.
+ *
+ * The trait allows the handler and return types to be determined at the point
+ * where the specific completion handler signature is known.
+ *
+ * This template may be specialised for user-defined completion token types.
+ * The primary template assumes that the CompletionToken is the completion
+ * handler.
+ */
+#if defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION)
+template <typename CompletionToken, typename Signature>
+#else // defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION)
+template <typename CompletionToken, typename Signature = void>
+#endif // defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION)
+class async_result
+{
+public:
+#if defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION)
+  /// The concrete completion handler type for the specific signature.
+  typedef CompletionToken completion_handler_type;
+
+  /// The return type of the initiating function.
+  typedef void return_type;
+#else // defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION)
+  // For backward compatibility, determine the concrete completion handler type
+  // by using the legacy handler_type trait.
+  typedef typename handler_type<CompletionToken, Signature>::type
+    completion_handler_type;
+
+  // For backward compatibility, determine the initiating function return type
+  // using the legacy single-parameter version of async_result.
+  typedef typename async_result<completion_handler_type>::type return_type;
+#endif // defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION)
+
+  /// Construct an async result from a given handler.
+  /**
+   * When using a specalised async_result, the constructor has an opportunity
+   * to initialise some state associated with the completion handler, which is
+   * then returned from the initiating function.
+   */
+  explicit async_result(completion_handler_type& h)
+#if defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION)
+    // No data members to initialise.
+#else // defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION)
+    : legacy_result_(h)
+#endif // defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION)
+  {
+    (void)h;
+  }
+
+  /// Obtain the value to be returned from the initiating function.
+  return_type get()
+  {
+#if defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION)
+    // Nothing to do.
+#else // defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION)
+    return legacy_result_.get();
+#endif // defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION)
+  }
+
+private:
+  async_result(const async_result&) ASIO_DELETED;
+  async_result& operator=(const async_result&) ASIO_DELETED;
+
+#if defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION)
+  // No data members.
+#else // defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION)
+  async_result<completion_handler_type> legacy_result_;
+#endif // defined(ASIO_NO_DEPRECATED) || defined(GENERATING_DOCUMENTATION)
+};
+
+#if !defined(ASIO_NO_DEPRECATED)
+
+/// (Deprecated: Use two-parameter version of async_result.) An interface for
+/// customising the behaviour of an initiating function.
+/**
  * This template may be specialised for user-defined handler types.
  */
 template <typename Handler>
-class async_result
+class async_result<Handler>
 {
 public:
   /// The return type of the initiating function.
@@ -50,33 +133,42 @@
   }
 };
 
-/// Helper template to deduce the real type of a handler, capture a local copy
-/// of the handler, and then create an async_result for the handler.
-template <typename Handler, typename Signature>
+#endif // !defined(ASIO_NO_DEPRECATED)
+
+/// Helper template to deduce the handler type from a CompletionToken, capture
+/// a local copy of the handler, and then create an async_result for the
+/// handler.
+template <typename CompletionToken, typename Signature>
 struct async_completion
 {
   /// The real handler type to be used for the asynchronous operation.
-  typedef typename asio::handler_type<
-    Handler, Signature>::type handler_type;
+  typedef typename asio::async_result<
+    typename decay<CompletionToken>::type,
+      Signature>::completion_handler_type completion_handler_type;
 
+#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
   /// Constructor.
   /**
-   * The constructor creates the concrete handler and makes the link between
-   * the handler and the asynchronous result.
+   * The constructor creates the concrete completion handler and makes the link
+   * between the handler and the asynchronous result.
    */
-#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
-  explicit async_completion(
-      Handler& orig_handler)
-    : handler(static_cast<typename conditional<
-        is_same<Handler, handler_type>::value,
-        handler_type&, Handler&&>::type>(orig_handler)),
-      result(handler)
+  explicit async_completion(CompletionToken& token)
+    : completion_handler(static_cast<typename conditional<
+        is_same<CompletionToken, completion_handler_type>::value,
+        completion_handler_type&, CompletionToken&&>::type>(token)),
+      result(completion_handler)
   {
   }
 #else // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
-  explicit async_completion(const Handler& orig_handler)
-    : handler(orig_handler),
-      result(handler)
+  explicit async_completion(typename decay<CompletionToken>::type& token)
+    : completion_handler(token),
+      result(completion_handler)
+  {
+  }
+
+  explicit async_completion(const typename decay<CompletionToken>::type& token)
+    : completion_handler(token),
+      result(completion_handler)
   {
   }
 #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
@@ -84,25 +176,22 @@
   /// A copy of, or reference to, a real handler object.
 #if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
   typename conditional<
-    is_same<Handler, handler_type>::value,
-    handler_type&, handler_type>::type handler;
+    is_same<CompletionToken, completion_handler_type>::value,
+    completion_handler_type&, completion_handler_type>::type completion_handler;
 #else // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
-  typename asio::handler_type<Handler, Signature>::type handler;
+  completion_handler_type completion_handler;
 #endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
 
   /// The result of the asynchronous operation's initiating function.
-  async_result<typename asio::handler_type<
-    Handler, Signature>::type> result;
+  async_result<typename decay<CompletionToken>::type, Signature> result;
 };
 
 namespace detail {
 
-template <typename Handler, typename Signature>
-struct async_result_type_helper
+template <typename CompletionToken, typename Signature>
+struct async_result_helper
+  : async_result<typename decay<CompletionToken>::type, Signature>
 {
-  typedef typename async_result<
-      typename handler_type<Handler, Signature>::type
-    >::type type;
 };
 
 } // namespace detail
@@ -111,15 +200,22 @@
 #include "asio/detail/pop_options.hpp"
 
 #if defined(GENERATING_DOCUMENTATION)
-# define ASIO_INITFN_RESULT_TYPE(h, sig) \
+# define ASIO_INITFN_RESULT_TYPE(ct, sig) \
   void_or_deduced
 #elif defined(_MSC_VER) && (_MSC_VER < 1500)
-# define ASIO_INITFN_RESULT_TYPE(h, sig) \
-  typename ::asio::detail::async_result_type_helper<h, sig>::type
+# define ASIO_INITFN_RESULT_TYPE(ct, sig) \
+  typename ::asio::detail::async_result_helper< \
+    ct, sig>::return_type
+#define ASIO_HANDLER_TYPE(ct, sig) \
+  typename ::asio::detail::async_result_helper< \
+    ct, sig>::completion_handler_type
 #else
-# define ASIO_INITFN_RESULT_TYPE(h, sig) \
+# define ASIO_INITFN_RESULT_TYPE(ct, sig) \
   typename ::asio::async_result< \
-    typename ::asio::handler_type<h, sig>::type>::type
+    typename ::asio::decay<ct>::type, sig>::return_type
+#define ASIO_HANDLER_TYPE(ct, sig) \
+  typename ::asio::async_result< \
+    typename ::asio::decay<ct>::type, sig>::completion_handler_type
 #endif
 
 #endif // ASIO_ASYNC_RESULT_HPP
diff --git a/asio/include/asio/basic_datagram_socket.hpp b/asio/include/asio/basic_datagram_socket.hpp
index f72ebbf..a3339f4 100644
--- a/asio/include/asio/basic_datagram_socket.hpp
+++ b/asio/include/asio/basic_datagram_socket.hpp
@@ -354,7 +354,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     this->get_service().async_send(this->get_implementation(),
-        buffers, 0, init.handler);
+        buffers, 0, init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -407,7 +407,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     this->get_service().async_send(this->get_implementation(),
-        buffers, flags, init.handler);
+        buffers, flags, init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -559,7 +559,7 @@
 
     this->get_service().async_send_to(
         this->get_implementation(), buffers, destination, 0,
-        init.handler);
+        init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -613,7 +613,7 @@
 
     this->get_service().async_send_to(
         this->get_implementation(), buffers, destination, flags,
-        init.handler);
+        init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -762,7 +762,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     this->get_service().async_receive(this->get_implementation(),
-        buffers, 0, init.handler);
+        buffers, 0, init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -815,7 +815,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     this->get_service().async_receive(this->get_implementation(),
-        buffers, flags, init.handler);
+        buffers, flags, init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -967,7 +967,7 @@
 
     this->get_service().async_receive_from(
         this->get_implementation(), buffers, sender_endpoint, 0,
-        init.handler);
+        init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -1023,7 +1023,7 @@
 
     this->get_service().async_receive_from(
         this->get_implementation(), buffers, sender_endpoint, flags,
-        init.handler);
+        init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
diff --git a/asio/include/asio/basic_deadline_timer.hpp b/asio/include/asio/basic_deadline_timer.hpp
index 24ddec2..2d15884 100644
--- a/asio/include/asio/basic_deadline_timer.hpp
+++ b/asio/include/asio/basic_deadline_timer.hpp
@@ -571,7 +571,8 @@
     async_completion<WaitHandler,
       void (asio::error_code)> init(handler);
 
-    this->get_service().async_wait(this->get_implementation(), init.handler);
+    this->get_service().async_wait(this->get_implementation(),
+        init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
diff --git a/asio/include/asio/basic_raw_socket.hpp b/asio/include/asio/basic_raw_socket.hpp
index b66b75d..8e12e7c 100644
--- a/asio/include/asio/basic_raw_socket.hpp
+++ b/asio/include/asio/basic_raw_socket.hpp
@@ -346,7 +346,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     this->get_service().async_send(this->get_implementation(),
-        buffers, 0, init.handler);
+        buffers, 0, init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -399,7 +399,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     this->get_service().async_send(this->get_implementation(),
-        buffers, flags, init.handler);
+        buffers, flags, init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -549,7 +549,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     this->get_service().async_send_to(this->get_implementation(),
-        buffers, destination, 0, init.handler);
+        buffers, destination, 0, init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -603,7 +603,7 @@
 
     this->get_service().async_send_to(
         this->get_implementation(), buffers, destination, flags,
-        init.handler);
+        init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -752,7 +752,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     this->get_service().async_receive(this->get_implementation(),
-        buffers, 0, init.handler);
+        buffers, 0, init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -805,7 +805,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     this->get_service().async_receive(this->get_implementation(),
-        buffers, flags, init.handler);
+        buffers, flags, init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -957,7 +957,7 @@
 
     this->get_service().async_receive_from(
         this->get_implementation(), buffers, sender_endpoint, 0,
-        init.handler);
+        init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -1013,7 +1013,7 @@
 
     this->get_service().async_receive_from(
         this->get_implementation(), buffers, sender_endpoint, flags,
-        init.handler);
+        init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
diff --git a/asio/include/asio/basic_seq_packet_socket.hpp b/asio/include/asio/basic_seq_packet_socket.hpp
index ec2ab8f..b0b2e79 100644
--- a/asio/include/asio/basic_seq_packet_socket.hpp
+++ b/asio/include/asio/basic_seq_packet_socket.hpp
@@ -332,7 +332,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     this->get_service().async_send(this->get_implementation(),
-        buffers, flags, init.handler);
+        buffers, flags, init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -531,7 +531,7 @@
 
     this->get_service().async_receive_with_flags(
         this->get_implementation(), buffers, 0, out_flags,
-        init.handler);
+        init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -601,7 +601,7 @@
 
     this->get_service().async_receive_with_flags(
         this->get_implementation(), buffers, in_flags, out_flags,
-        init.handler);
+        init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
diff --git a/asio/include/asio/basic_socket.hpp b/asio/include/asio/basic_socket.hpp
index c4ae0df..c62e1ea 100644
--- a/asio/include/asio/basic_socket.hpp
+++ b/asio/include/asio/basic_socket.hpp
@@ -812,7 +812,7 @@
             asio::detail::bind_handler(
               ASIO_MOVE_CAST(ASIO_HANDLER_TYPE(
                 ConnectHandler, void (asio::error_code)))(
-                  init.handler), ec));
+                  init.completion_handler), ec));
 
         return init.result.get();
       }
@@ -826,7 +826,7 @@
       void (asio::error_code)> init(handler);
 
     this->get_service().async_connect(
-        this->get_implementation(), peer_endpoint, init.handler);
+        this->get_implementation(), peer_endpoint, init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -1658,7 +1658,8 @@
     async_completion<WaitHandler,
       void (asio::error_code)> init(handler);
 
-    this->get_service().async_wait(this->get_implementation(), w, init.handler);
+    this->get_service().async_wait(this->get_implementation(),
+        w, init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
diff --git a/asio/include/asio/basic_socket_acceptor.hpp b/asio/include/asio/basic_socket_acceptor.hpp
index 3d8b7e5..2e9da59 100644
--- a/asio/include/asio/basic_socket_acceptor.hpp
+++ b/asio/include/asio/basic_socket_acceptor.hpp
@@ -1060,7 +1060,8 @@
     async_completion<WaitHandler,
       void (asio::error_code)> init(handler);
 
-    this->get_service().async_wait(this->get_implementation(), w, init.handler);
+    this->get_service().async_wait(this->get_implementation(),
+        w, init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -1207,7 +1208,7 @@
       void (asio::error_code)> init(handler);
 
     this->get_service().async_accept(this->get_implementation(),
-        peer, static_cast<endpoint_type*>(0), init.handler);
+        peer, static_cast<endpoint_type*>(0), init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -1344,7 +1345,7 @@
       void (asio::error_code)> init(handler);
 
     this->get_service().async_accept(this->get_implementation(),
-        peer, &peer_endpoint, init.handler);
+        peer, &peer_endpoint, init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -1471,7 +1472,7 @@
 
     this->get_service().async_accept(
         this->get_implementation(), static_cast<asio::io_context*>(0),
-        static_cast<endpoint_type*>(0), init.handler);
+        static_cast<endpoint_type*>(0), init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -1607,7 +1608,7 @@
         typename Protocol::socket)> init(handler);
 
     this->get_service().async_accept(this->get_implementation(),
-        &io_context, static_cast<endpoint_type*>(0), init.handler);
+        &io_context, static_cast<endpoint_type*>(0), init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -1748,7 +1749,8 @@
         typename Protocol::socket)> init(handler);
 
     this->get_service().async_accept(this->get_implementation(),
-        static_cast<asio::io_context*>(0), &peer_endpoint, init.handler);
+        static_cast<asio::io_context*>(0), &peer_endpoint,
+        init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -1902,7 +1904,7 @@
         typename Protocol::socket)> init(handler);
 
     this->get_service().async_accept(this->get_implementation(),
-        &io_context, &peer_endpoint, init.handler);
+        &io_context, &peer_endpoint, init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
diff --git a/asio/include/asio/basic_stream_socket.hpp b/asio/include/asio/basic_stream_socket.hpp
index c3eef8c..0eb7620 100644
--- a/asio/include/asio/basic_stream_socket.hpp
+++ b/asio/include/asio/basic_stream_socket.hpp
@@ -368,7 +368,7 @@
 
     this->get_service().async_send(
         this->get_implementation(), buffers, 0,
-        init.handler);
+        init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -432,7 +432,7 @@
 
     this->get_service().async_send(
         this->get_implementation(), buffers, flags,
-        init.handler);
+        init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -598,7 +598,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     this->get_service().async_receive(this->get_implementation(),
-        buffers, 0, init.handler);
+        buffers, 0, init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -662,7 +662,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     this->get_service().async_receive(this->get_implementation(),
-        buffers, flags, init.handler);
+        buffers, flags, init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -781,7 +781,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     this->get_service().async_send(this->get_implementation(),
-        buffers, 0, init.handler);
+        buffers, 0, init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -904,7 +904,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     this->get_service().async_receive(this->get_implementation(),
-        buffers, 0, init.handler);
+        buffers, 0, init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
diff --git a/asio/include/asio/basic_waitable_timer.hpp b/asio/include/asio/basic_waitable_timer.hpp
index e6032c3..e38d39e 100644
--- a/asio/include/asio/basic_waitable_timer.hpp
+++ b/asio/include/asio/basic_waitable_timer.hpp
@@ -670,7 +670,8 @@
     async_completion<WaitHandler,
       void (asio::error_code)> init(handler);
 
-    this->get_service().async_wait(this->get_implementation(), init.handler);
+    this->get_service().async_wait(this->get_implementation(),
+        init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
diff --git a/asio/include/asio/bind_executor.hpp b/asio/include/asio/bind_executor.hpp
index f74a8e3..4b160a6 100644
--- a/asio/include/asio/bind_executor.hpp
+++ b/asio/include/asio/bind_executor.hpp
@@ -20,7 +20,6 @@
 #include "asio/detail/variadic_templates.hpp"
 #include "asio/associated_allocator.hpp"
 #include "asio/async_result.hpp"
-#include "asio/handler_type.hpp"
 #include "asio/is_executor.hpp"
 #include "asio/uses_executor.hpp"
 
@@ -520,6 +519,35 @@
   : true_type {};
 
 template <typename T, typename Executor, typename Signature>
+class async_result<executor_binder<T, Executor>, Signature>
+{
+public:
+  typedef executor_binder<
+    typename async_result<T, Signature>::completion_handler_type, Executor>
+      completion_handler_type;
+
+  typedef typename async_result<T, Signature>::return_type return_type;
+
+  explicit async_result(executor_binder<T, Executor>& b)
+    : target_(b.get())
+  {
+  }
+
+  return_type get()
+  {
+    return target_.get();
+  }
+
+private:
+  async_result(const async_result&) ASIO_DELETED;
+  async_result& operator=(const async_result&) ASIO_DELETED;
+
+  async_result<T, Signature> target_;
+};
+
+#if !defined(ASIO_NO_DEPRECATED)
+
+template <typename T, typename Executor, typename Signature>
 struct handler_type<executor_binder<T, Executor>, Signature>
 {
   typedef executor_binder<
@@ -546,6 +574,8 @@
   async_result<T> target_;
 };
 
+#endif // !defined(ASIO_NO_DEPRECATED)
+
 template <typename T, typename Executor, typename Allocator>
 struct associated_allocator<executor_binder<T, Executor>, Allocator>
 {
diff --git a/asio/include/asio/buffered_read_stream.hpp b/asio/include/asio/buffered_read_stream.hpp
index daa6f59..832ec17 100644
--- a/asio/include/asio/buffered_read_stream.hpp
+++ b/asio/include/asio/buffered_read_stream.hpp
@@ -163,7 +163,8 @@
 
     next_layer_.async_write_some(buffers,
         ASIO_MOVE_CAST(ASIO_HANDLER_TYPE(WriteHandler,
-            void (asio::error_code, std::size_t)))(init.handler));
+            void (asio::error_code, std::size_t)))(
+              init.completion_handler));
 
     return init.result.get();
   }
diff --git a/asio/include/asio/buffered_write_stream.hpp b/asio/include/asio/buffered_write_stream.hpp
index 0fa7547..9f2641f 100644
--- a/asio/include/asio/buffered_write_stream.hpp
+++ b/asio/include/asio/buffered_write_stream.hpp
@@ -198,7 +198,8 @@
 
     next_layer_.async_read_some(buffers,
         ASIO_MOVE_CAST(ASIO_HANDLER_TYPE(ReadHandler,
-            void (asio::error_code, std::size_t)))(init.handler));
+            void (asio::error_code, std::size_t)))(
+              init.completion_handler));
 
     return init.result.get();
   }
diff --git a/asio/include/asio/datagram_socket_service.hpp b/asio/include/asio/datagram_socket_service.hpp
index e22d07f..f578613 100644
--- a/asio/include/asio/datagram_socket_service.hpp
+++ b/asio/include/asio/datagram_socket_service.hpp
@@ -217,7 +217,7 @@
     async_completion<ConnectHandler,
       void (asio::error_code)> init(handler);
 
-    service_impl_.async_connect(impl, peer_endpoint, init.handler);
+    service_impl_.async_connect(impl, peer_endpoint, init.completion_handler);
 
     return init.result.get();
   }
@@ -312,7 +312,7 @@
     async_completion<WaitHandler,
       void (asio::error_code)> init(handler);
 
-    service_impl_.async_wait(impl, w, init.handler);
+    service_impl_.async_wait(impl, w, init.completion_handler);
 
     return init.result.get();
   }
@@ -337,7 +337,7 @@
     async_completion<WriteHandler,
       void (asio::error_code, std::size_t)> init(handler);
 
-    service_impl_.async_send(impl, buffers, flags, init.handler);
+    service_impl_.async_send(impl, buffers, flags, init.completion_handler);
 
     return init.result.get();
   }
@@ -364,7 +364,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     service_impl_.async_send_to(impl, buffers,
-        destination, flags, init.handler);
+        destination, flags, init.completion_handler);
 
     return init.result.get();
   }
@@ -390,7 +390,7 @@
     async_completion<ReadHandler,
       void (asio::error_code, std::size_t)> init(handler);
 
-    service_impl_.async_receive(impl, buffers, flags, init.handler);
+    service_impl_.async_receive(impl, buffers, flags, init.completion_handler);
 
     return init.result.get();
   }
@@ -418,7 +418,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     service_impl_.async_receive_from(impl, buffers,
-        sender_endpoint, flags, init.handler);
+        sender_endpoint, flags, init.completion_handler);
 
     return init.result.get();
   }
diff --git a/asio/include/asio/deadline_timer_service.hpp b/asio/include/asio/deadline_timer_service.hpp
index df87d54..a51bdae 100644
--- a/asio/include/asio/deadline_timer_service.hpp
+++ b/asio/include/asio/deadline_timer_service.hpp
@@ -145,7 +145,7 @@
     async_completion<WaitHandler,
       void (asio::error_code)> init(handler);
 
-    service_impl_.async_wait(impl, init.handler);
+    service_impl_.async_wait(impl, init.completion_handler);
 
     return init.result.get();
   }
diff --git a/asio/include/asio/detail/handler_type_requirements.hpp b/asio/include/asio/detail/handler_type_requirements.hpp
index 04bab88..1a7c359 100644
--- a/asio/include/asio/detail/handler_type_requirements.hpp
+++ b/asio/include/asio/detail/handler_type_requirements.hpp
@@ -50,7 +50,7 @@
 #endif // !defined(ASIO_DISABLE_HANDLER_TYPE_REQUIREMENTS)
 
 #if defined(ASIO_ENABLE_HANDLER_TYPE_REQUIREMENTS)
-# include "asio/handler_type.hpp"
+# include "asio/async_result.hpp"
 #endif // defined(ASIO_ENABLE_HANDLER_TYPE_REQUIREMENTS)
 
 // Newer gcc, clang need special treatment to suppress unused typedef warnings.
diff --git a/asio/include/asio/handler_type.hpp b/asio/include/asio/handler_type.hpp
index 260fbcb..809e363 100644
--- a/asio/include/asio/handler_type.hpp
+++ b/asio/include/asio/handler_type.hpp
@@ -22,7 +22,8 @@
 
 namespace asio {
 
-/// Default handler type traits provided for all completion token types.
+/// (Deprecated: Use two-parameter version of async_result.) Default handler
+/// type traits provided for all completion token types.
 /**
  * The handler_type traits class is used for determining the concrete handler
  * type to be used for an asynchronous operation. It allows the handler type to
@@ -46,7 +47,4 @@
 
 #include "asio/detail/pop_options.hpp"
 
-#define ASIO_HANDLER_TYPE(h, sig) \
-  typename handler_type<h, sig>::type
-
 #endif // ASIO_HANDLER_TYPE_HPP
diff --git a/asio/include/asio/impl/buffered_read_stream.hpp b/asio/include/asio/impl/buffered_read_stream.hpp
index 77700b8..5c53255 100644
--- a/asio/include/asio/impl/buffered_read_stream.hpp
+++ b/asio/include/asio/impl/buffered_read_stream.hpp
@@ -191,7 +191,7 @@
         storage_.size() - previous_size),
       detail::buffered_fill_handler<ASIO_HANDLER_TYPE(
         ReadHandler, void (asio::error_code, std::size_t))>(
-        storage_, previous_size, init.handler));
+        storage_, previous_size, init.completion_handler));
 
   return init.result.get();
 }
@@ -385,14 +385,14 @@
         detail::buffered_read_some_handler<
           MutableBufferSequence, ASIO_HANDLER_TYPE(
             ReadHandler, void (asio::error_code, std::size_t))>(
-            storage_, buffers, init.handler));
+            storage_, buffers, init.completion_handler));
   }
   else
   {
     this->async_fill(detail::buffered_read_some_handler<
           MutableBufferSequence, ASIO_HANDLER_TYPE(
             ReadHandler, void (asio::error_code, std::size_t))>(
-            storage_, buffers, init.handler));
+            storage_, buffers, init.completion_handler));
   }
 
   return init.result.get();
diff --git a/asio/include/asio/impl/buffered_write_stream.hpp b/asio/include/asio/impl/buffered_write_stream.hpp
index 125bd31..af55d1c 100644
--- a/asio/include/asio/impl/buffered_write_stream.hpp
+++ b/asio/include/asio/impl/buffered_write_stream.hpp
@@ -172,7 +172,7 @@
   async_write(next_layer_, buffer(storage_.data(), storage_.size()),
       detail::buffered_flush_handler<ASIO_HANDLER_TYPE(
         WriteHandler, void (asio::error_code, std::size_t))>(
-        storage_, init.handler));
+        storage_, init.completion_handler));
 
   return init.result.get();
 }
@@ -372,14 +372,14 @@
         detail::buffered_write_some_handler<
           ConstBufferSequence, ASIO_HANDLER_TYPE(
             WriteHandler, void (asio::error_code, std::size_t))>(
-            storage_, buffers, init.handler));
+            storage_, buffers, init.completion_handler));
   }
   else
   {
     this->async_flush(detail::buffered_write_some_handler<
           ConstBufferSequence, ASIO_HANDLER_TYPE(
             WriteHandler, void (asio::error_code, std::size_t))>(
-            storage_, buffers, init.handler));
+            storage_, buffers, init.completion_handler));
   }
 
   return init.result.get();
diff --git a/asio/include/asio/impl/connect.hpp b/asio/include/asio/impl/connect.hpp
index f8e3860..8680d12 100644
--- a/asio/include/asio/impl/connect.hpp
+++ b/asio/include/asio/impl/connect.hpp
@@ -659,8 +659,8 @@
     detail::default_connect_condition,
       ASIO_HANDLER_TYPE(RangeConnectHandler,
         void (asio::error_code, typename Protocol::endpoint))>(s,
-          endpoints, detail::default_connect_condition(), init.handler)(
-            asio::error_code(), 1);
+          endpoints, detail::default_connect_condition(),
+            init.completion_handler)(asio::error_code(), 1);
 
   return init.result.get();
 }
@@ -685,8 +685,8 @@
   detail::iterator_connect_op<Protocol ASIO_SVC_TARG, Iterator,
     detail::default_connect_condition, ASIO_HANDLER_TYPE(
       IteratorConnectHandler, void (asio::error_code, Iterator))>(s,
-        begin, Iterator(), detail::default_connect_condition(), init.handler)(
-          asio::error_code(), 1);
+        begin, Iterator(), detail::default_connect_condition(),
+          init.completion_handler)(asio::error_code(), 1);
 
   return init.result.get();
 }
@@ -711,8 +711,8 @@
   detail::iterator_connect_op<Protocol ASIO_SVC_TARG, Iterator,
     detail::default_connect_condition, ASIO_HANDLER_TYPE(
       IteratorConnectHandler, void (asio::error_code, Iterator))>(s,
-        begin, end, detail::default_connect_condition(), init.handler)(
-          asio::error_code(), 1);
+        begin, end, detail::default_connect_condition(),
+          init.completion_handler)(asio::error_code(), 1);
 
   return init.result.get();
 }
@@ -739,7 +739,7 @@
   detail::range_connect_op<Protocol ASIO_SVC_TARG, EndpointSequence,
     ConnectCondition, ASIO_HANDLER_TYPE(RangeConnectHandler,
       void (asio::error_code, typename Protocol::endpoint))>(s,
-        endpoints, connect_condition, init.handler)(
+        endpoints, connect_condition, init.completion_handler)(
           asio::error_code(), 1);
 
   return init.result.get();
@@ -766,7 +766,7 @@
   detail::iterator_connect_op<Protocol ASIO_SVC_TARG, Iterator,
     ConnectCondition, ASIO_HANDLER_TYPE(
       IteratorConnectHandler, void (asio::error_code, Iterator))>(s,
-        begin, Iterator(), connect_condition, init.handler)(
+        begin, Iterator(), connect_condition, init.completion_handler)(
           asio::error_code(), 1);
 
   return init.result.get();
@@ -792,7 +792,7 @@
   detail::iterator_connect_op<Protocol ASIO_SVC_TARG, Iterator,
     ConnectCondition, ASIO_HANDLER_TYPE(
       IteratorConnectHandler, void (asio::error_code, Iterator))>(s,
-        begin, end, connect_condition, init.handler)(
+        begin, end, connect_condition, init.completion_handler)(
           asio::error_code(), 1);
 
   return init.result.get();
diff --git a/asio/include/asio/impl/defer.hpp b/asio/include/asio/impl/defer.hpp
index 5a12176..8cbd761 100644
--- a/asio/include/asio/impl/defer.hpp
+++ b/asio/include/asio/impl/defer.hpp
@@ -28,18 +28,19 @@
 ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) defer(
     ASIO_MOVE_ARG(CompletionToken) token)
 {
-  typedef typename handler_type<CompletionToken, void()>::type handler;
-  async_completion<CompletionToken, void()> completion(token);
+  typedef ASIO_HANDLER_TYPE(CompletionToken, void()) handler;
+
+  async_completion<CompletionToken, void()> init(token);
 
   typename associated_executor<handler>::type ex(
-      (get_associated_executor)(completion.handler));
+      (get_associated_executor)(init.completion_handler));
 
   typename associated_allocator<handler>::type alloc(
-      (get_associated_allocator)(completion.handler));
+      (get_associated_allocator)(init.completion_handler));
 
-  ex.defer(ASIO_MOVE_CAST(handler)(completion.handler), alloc);
+  ex.defer(ASIO_MOVE_CAST(handler)(init.completion_handler), alloc);
 
-  return completion.result.get();
+  return init.result.get();
 }
 
 template <typename Executor, typename CompletionToken>
@@ -47,17 +48,18 @@
     const Executor& ex, ASIO_MOVE_ARG(CompletionToken) token,
     typename enable_if<is_executor<Executor>::value>::type*)
 {
-  typedef typename handler_type<CompletionToken, void()>::type handler;
-  async_completion<CompletionToken, void()> completion(token);
+  typedef ASIO_HANDLER_TYPE(CompletionToken, void()) handler;
+
+  async_completion<CompletionToken, void()> init(token);
 
   Executor ex1(ex);
 
   typename associated_allocator<handler>::type alloc(
-      (get_associated_allocator)(completion.handler));
+      (get_associated_allocator)(init.completion_handler));
 
-  ex1.defer(detail::work_dispatcher<handler>(completion.handler), alloc);
+  ex1.defer(detail::work_dispatcher<handler>(init.completion_handler), alloc);
 
-  return completion.result.get();
+  return init.result.get();
 }
 
 template <typename ExecutionContext, typename CompletionToken>
diff --git a/asio/include/asio/impl/dispatch.hpp b/asio/include/asio/impl/dispatch.hpp
index 42d5fa9..aaeab70 100644
--- a/asio/include/asio/impl/dispatch.hpp
+++ b/asio/include/asio/impl/dispatch.hpp
@@ -28,18 +28,19 @@
 ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) dispatch(
     ASIO_MOVE_ARG(CompletionToken) token)
 {
-  typedef typename handler_type<CompletionToken, void()>::type handler;
-  async_completion<CompletionToken, void()> completion(token);
+  typedef ASIO_HANDLER_TYPE(CompletionToken, void()) handler;
+
+  async_completion<CompletionToken, void()> init(token);
 
   typename associated_executor<handler>::type ex(
-      (get_associated_executor)(completion.handler));
+      (get_associated_executor)(init.completion_handler));
 
   typename associated_allocator<handler>::type alloc(
-      (get_associated_allocator)(completion.handler));
+      (get_associated_allocator)(init.completion_handler));
 
-  ex.dispatch(ASIO_MOVE_CAST(handler)(completion.handler), alloc);
+  ex.dispatch(ASIO_MOVE_CAST(handler)(init.completion_handler), alloc);
 
-  return completion.result.get();
+  return init.result.get();
 }
 
 template <typename Executor, typename CompletionToken>
@@ -47,17 +48,19 @@
     const Executor& ex, ASIO_MOVE_ARG(CompletionToken) token,
     typename enable_if<is_executor<Executor>::value>::type*)
 {
-  typedef typename handler_type<CompletionToken, void()>::type handler;
-  async_completion<CompletionToken, void()> completion(token);
+  typedef ASIO_HANDLER_TYPE(CompletionToken, void()) handler;
+
+  async_completion<CompletionToken, void()> init(token);
 
   Executor ex1(ex);
 
   typename associated_allocator<handler>::type alloc(
-      (get_associated_allocator)(completion.handler));
+      (get_associated_allocator)(init.completion_handler));
 
-  ex1.dispatch(detail::work_dispatcher<handler>(completion.handler), alloc);
+  ex1.dispatch(detail::work_dispatcher<handler>(
+        init.completion_handler), alloc);
 
-  return completion.result.get();
+  return init.result.get();
 }
 
 template <typename ExecutionContext, typename CompletionToken>
diff --git a/asio/include/asio/impl/io_context.hpp b/asio/include/asio/impl/io_context.hpp
index 2e80c3c..adcac14 100644
--- a/asio/include/asio/impl/io_context.hpp
+++ b/asio/include/asio/impl/io_context.hpp
@@ -84,16 +84,17 @@
   if (impl_.can_dispatch())
   {
     detail::fenced_block b(detail::fenced_block::full);
-    asio_handler_invoke_helpers::invoke(init.handler, init.handler);
+    asio_handler_invoke_helpers::invoke(
+        init.completion_handler, init.completion_handler);
   }
   else
   {
     // Allocate and construct an operation to wrap the handler.
     typedef detail::completion_handler<
       typename handler_type<CompletionHandler, void ()>::type> op;
-    typename op::ptr p = { detail::addressof(init.handler),
-      op::ptr::allocate(init.handler), 0 };
-    p.p = new (p.v) op(init.handler);
+    typename op::ptr p = { detail::addressof(init.completion_handler),
+      op::ptr::allocate(init.completion_handler), 0 };
+    p.p = new (p.v) op(init.completion_handler);
 
     ASIO_HANDLER_CREATION((*this, *p.p,
           "io_context", this, 0, "dispatch"));
@@ -116,14 +117,14 @@
   async_completion<CompletionHandler, void ()> init(handler);
 
   bool is_continuation =
-    asio_handler_cont_helpers::is_continuation(init.handler);
+    asio_handler_cont_helpers::is_continuation(init.completion_handler);
 
   // Allocate and construct an operation to wrap the handler.
   typedef detail::completion_handler<
     typename handler_type<CompletionHandler, void ()>::type> op;
-  typename op::ptr p = { detail::addressof(init.handler),
-      op::ptr::allocate(init.handler), 0 };
-  p.p = new (p.v) op(init.handler);
+  typename op::ptr p = { detail::addressof(init.completion_handler),
+      op::ptr::allocate(init.completion_handler), 0 };
+  p.p = new (p.v) op(init.completion_handler);
 
   ASIO_HANDLER_CREATION((*this, *p.p,
         "io_context", this, 0, "post"));
diff --git a/asio/include/asio/impl/post.hpp b/asio/include/asio/impl/post.hpp
index 5d034d0..659455a 100644
--- a/asio/include/asio/impl/post.hpp
+++ b/asio/include/asio/impl/post.hpp
@@ -28,18 +28,19 @@
 ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) post(
     ASIO_MOVE_ARG(CompletionToken) token)
 {
-  typedef typename handler_type<CompletionToken, void()>::type handler;
-  async_completion<CompletionToken, void()> completion(token);
+  typedef ASIO_HANDLER_TYPE(CompletionToken, void()) handler;
+
+  async_completion<CompletionToken, void()> init(token);
 
   typename associated_executor<handler>::type ex(
-      (get_associated_executor)(completion.handler));
+      (get_associated_executor)(init.completion_handler));
 
   typename associated_allocator<handler>::type alloc(
-      (get_associated_allocator)(completion.handler));
+      (get_associated_allocator)(init.completion_handler));
 
-  ex.post(ASIO_MOVE_CAST(handler)(completion.handler), alloc);
+  ex.post(ASIO_MOVE_CAST(handler)(init.completion_handler), alloc);
 
-  return completion.result.get();
+  return init.result.get();
 }
 
 template <typename Executor, typename CompletionToken>
@@ -47,17 +48,18 @@
     const Executor& ex, ASIO_MOVE_ARG(CompletionToken) token,
     typename enable_if<is_executor<Executor>::value>::type*)
 {
-  typedef typename handler_type<CompletionToken, void()>::type handler;
-  async_completion<CompletionToken, void()> completion(token);
+  typedef ASIO_HANDLER_TYPE(CompletionToken, void()) handler;
+
+  async_completion<CompletionToken, void()> init(token);
 
   Executor ex1(ex);
 
   typename associated_allocator<handler>::type alloc(
-      (get_associated_allocator)(completion.handler));
+      (get_associated_allocator)(init.completion_handler));
 
-  ex1.post(detail::work_dispatcher<handler>(completion.handler), alloc);
+  ex1.post(detail::work_dispatcher<handler>(init.completion_handler), alloc);
 
-  return completion.result.get();
+  return init.result.get();
 }
 
 template <typename ExecutionContext, typename CompletionToken>
diff --git a/asio/include/asio/impl/read.hpp b/asio/include/asio/impl/read.hpp
index 8545732..3b37d25 100644
--- a/asio/include/asio/impl/read.hpp
+++ b/asio/include/asio/impl/read.hpp
@@ -645,7 +645,7 @@
   detail::read_op<AsyncReadStream, MutableBufferSequence,
     CompletionCondition, ASIO_HANDLER_TYPE(
       ReadHandler, void (asio::error_code, std::size_t))>(
-        s, buffers, completion_condition, init.handler)(
+        s, buffers, completion_condition, init.completion_handler)(
           asio::error_code(), 0, 1);
 
   return init.result.get();
@@ -671,7 +671,7 @@
   detail::read_op<AsyncReadStream, MutableBufferSequence,
     detail::transfer_all_t, ASIO_HANDLER_TYPE(
       ReadHandler, void (asio::error_code, std::size_t))>(
-        s, buffers, transfer_all(), init.handler)(
+        s, buffers, transfer_all(), init.completion_handler)(
           asio::error_code(), 0, 1);
 
   return init.result.get();
@@ -897,7 +897,7 @@
       CompletionCondition, ASIO_HANDLER_TYPE(
         ReadHandler, void (asio::error_code, std::size_t))>(
           s, ASIO_MOVE_CAST(DynamicBufferSequence)(buffers),
-            completion_condition, init.handler)(
+            completion_condition, init.completion_handler)(
               asio::error_code(), 0, 1);
 
   return init.result.get();
diff --git a/asio/include/asio/impl/read_at.hpp b/asio/include/asio/impl/read_at.hpp
index 22882c6..9a6413b 100644
--- a/asio/include/asio/impl/read_at.hpp
+++ b/asio/include/asio/impl/read_at.hpp
@@ -624,7 +624,7 @@
   detail::read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence,
     CompletionCondition, ASIO_HANDLER_TYPE(ReadHandler,
       void (asio::error_code, std::size_t))>(
-        d, offset, buffers, completion_condition, init.handler)(
+        d, offset, buffers, completion_condition, init.completion_handler)(
           asio::error_code(), 0, 1);
 
   return init.result.get();
@@ -648,7 +648,7 @@
   detail::read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence,
     detail::transfer_all_t, ASIO_HANDLER_TYPE(ReadHandler,
       void (asio::error_code, std::size_t))>(
-        d, offset, buffers, transfer_all(), init.handler)(
+        d, offset, buffers, transfer_all(), init.completion_handler)(
           asio::error_code(), 0, 1);
 
   return init.result.get();
@@ -849,7 +849,7 @@
   detail::read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator,
     CompletionCondition, ASIO_HANDLER_TYPE(ReadHandler,
       void (asio::error_code, std::size_t))>(
-        d, offset, b, completion_condition, init.handler)(
+        d, offset, b, completion_condition, init.completion_handler)(
           asio::error_code(), 0, 1);
 
   return init.result.get();
@@ -873,7 +873,7 @@
   detail::read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator,
     detail::transfer_all_t, ASIO_HANDLER_TYPE(ReadHandler,
       void (asio::error_code, std::size_t))>(
-        d, offset, b, transfer_all(), init.handler)(
+        d, offset, b, transfer_all(), init.completion_handler)(
           asio::error_code(), 0, 1);
 
   return init.result.get();
diff --git a/asio/include/asio/impl/read_until.hpp b/asio/include/asio/impl/read_until.hpp
index de0569b..79d9845 100644
--- a/asio/include/asio/impl/read_until.hpp
+++ b/asio/include/asio/impl/read_until.hpp
@@ -656,7 +656,7 @@
       ASIO_HANDLER_TYPE(ReadHandler,
         void (asio::error_code, std::size_t))>(
           s, ASIO_MOVE_CAST(DynamicBufferSequence)(buffers),
-            delim, init.handler)(asio::error_code(), 0, 1);
+            delim, init.completion_handler)(asio::error_code(), 0, 1);
 
   return init.result.get();
 }
@@ -909,7 +909,7 @@
       ASIO_HANDLER_TYPE(ReadHandler,
         void (asio::error_code, std::size_t))>(
           s, ASIO_MOVE_CAST(DynamicBufferSequence)(buffers),
-            delim, init.handler)(asio::error_code(), 0, 1);
+            delim, init.completion_handler)(asio::error_code(), 0, 1);
 
   return init.result.get();
 }
@@ -1168,7 +1168,7 @@
       boost::regex, ASIO_HANDLER_TYPE(ReadHandler,
         void (asio::error_code, std::size_t))>(
           s, ASIO_MOVE_CAST(DynamicBufferSequence)(buffers),
-            expr, init.handler)(asio::error_code(), 0, 1);
+            expr, init.completion_handler)(asio::error_code(), 0, 1);
 
   return init.result.get();
 }
@@ -1425,7 +1425,8 @@
       MatchCondition, ASIO_HANDLER_TYPE(ReadHandler,
         void (asio::error_code, std::size_t))>(
           s, ASIO_MOVE_CAST(DynamicBufferSequence)(buffers),
-            match_condition, init.handler)(asio::error_code(), 0, 1);
+            match_condition, init.completion_handler)(
+              asio::error_code(), 0, 1);
 
   return init.result.get();
 }
diff --git a/asio/include/asio/impl/spawn.hpp b/asio/include/asio/impl/spawn.hpp
index a69df96..61461d8 100644
--- a/asio/include/asio/impl/spawn.hpp
+++ b/asio/include/asio/impl/spawn.hpp
@@ -26,7 +26,6 @@
 #include "asio/detail/handler_invoke_helpers.hpp"
 #include "asio/detail/memory.hpp"
 #include "asio/detail/noncopyable.hpp"
-#include "asio/handler_type.hpp"
 #include "asio/system_error.hpp"
 
 #include "asio/detail/push_options.hpp"
diff --git a/asio/include/asio/impl/use_future.hpp b/asio/include/asio/impl/use_future.hpp
index fd3857f..f3f7d59 100644
--- a/asio/include/asio/impl/use_future.hpp
+++ b/asio/include/asio/impl/use_future.hpp
@@ -19,7 +19,6 @@
 #include <future>
 #include "asio/async_result.hpp"
 #include "asio/error_code.hpp"
-#include "asio/handler_type.hpp"
 #include "asio/system_error.hpp"
 
 #include "asio/detail/push_options.hpp"
diff --git a/asio/include/asio/impl/write.hpp b/asio/include/asio/impl/write.hpp
index 4fbfc44..af59b8d 100644
--- a/asio/include/asio/impl/write.hpp
+++ b/asio/include/asio/impl/write.hpp
@@ -705,7 +705,7 @@
   detail::write_op<AsyncWriteStream, ConstBufferSequence,
     CompletionCondition, ASIO_HANDLER_TYPE(
       WriteHandler, void (asio::error_code, std::size_t))>(
-        s, buffers, completion_condition, init.handler)(
+        s, buffers, completion_condition, init.completion_handler)(
           asio::error_code(), 0, 1);
 
   return init.result.get();
@@ -731,7 +731,7 @@
   detail::write_op<AsyncWriteStream, ConstBufferSequence,
     detail::transfer_all_t, ASIO_HANDLER_TYPE(
       WriteHandler, void (asio::error_code, std::size_t))>(
-        s, buffers, transfer_all(), init.handler)(
+        s, buffers, transfer_all(), init.completion_handler)(
           asio::error_code(), 0, 1);
 
   return init.result.get();
@@ -930,7 +930,7 @@
       CompletionCondition, ASIO_HANDLER_TYPE(
         WriteHandler, void (asio::error_code, std::size_t))>(
           s, ASIO_MOVE_CAST(DynamicBufferSequence)(buffers),
-            completion_condition, init.handler)(
+            completion_condition, init.completion_handler)(
               asio::error_code(), 0, 1);
 
   return init.result.get();
diff --git a/asio/include/asio/impl/write_at.hpp b/asio/include/asio/impl/write_at.hpp
index 9303c5c..3412ba0 100644
--- a/asio/include/asio/impl/write_at.hpp
+++ b/asio/include/asio/impl/write_at.hpp
@@ -686,7 +686,7 @@
   detail::write_at_op<AsyncRandomAccessWriteDevice, ConstBufferSequence,
     CompletionCondition, ASIO_HANDLER_TYPE(
       WriteHandler, void (asio::error_code, std::size_t))>(
-        d, offset, buffers, completion_condition, init.handler)(
+        d, offset, buffers, completion_condition, init.completion_handler)(
           asio::error_code(), 0, 1);
 
   return init.result.get();
@@ -710,7 +710,7 @@
   detail::write_at_op<AsyncRandomAccessWriteDevice, ConstBufferSequence,
     detail::transfer_all_t, ASIO_HANDLER_TYPE(
       WriteHandler, void (asio::error_code, std::size_t))>(
-        d, offset, buffers, transfer_all(), init.handler)(
+        d, offset, buffers, transfer_all(), init.completion_handler)(
           asio::error_code(), 0, 1);
 
   return init.result.get();
@@ -860,7 +860,7 @@
   async_write_at(d, offset, b.data(), completion_condition,
     detail::write_at_streambuf_op<Allocator, ASIO_HANDLER_TYPE(
       WriteHandler, void (asio::error_code, std::size_t))>(
-        b, init.handler));
+        b, init.completion_handler));
 
   return init.result.get();
 }
@@ -883,7 +883,7 @@
   async_write_at(d, offset, b.data(), transfer_all(),
     detail::write_at_streambuf_op<Allocator, ASIO_HANDLER_TYPE(
       WriteHandler, void (asio::error_code, std::size_t))>(
-        b, init.handler));
+        b, init.completion_handler));
 
   return init.result.get();
 }
diff --git a/asio/include/asio/io_context_strand.hpp b/asio/include/asio/io_context_strand.hpp
index 78bb854..8c0b057 100644
--- a/asio/include/asio/io_context_strand.hpp
+++ b/asio/include/asio/io_context_strand.hpp
@@ -218,7 +218,7 @@
 
     async_completion<CompletionHandler, void ()> init(handler);
 
-    service_.dispatch(impl_, init.handler);
+    service_.dispatch(impl_, init.completion_handler);
 
     return init.result.get();
   }
@@ -272,7 +272,7 @@
 
     async_completion<CompletionHandler, void ()> init(handler);
 
-    service_.post(impl_, init.handler);
+    service_.post(impl_, init.completion_handler);
 
     return init.result.get();
   }
diff --git a/asio/include/asio/ip/basic_resolver.hpp b/asio/include/asio/ip/basic_resolver.hpp
index ca4f8f9..629a7a5 100644
--- a/asio/include/asio/ip/basic_resolver.hpp
+++ b/asio/include/asio/ip/basic_resolver.hpp
@@ -633,7 +633,7 @@
       void (asio::error_code, results_type)> init(handler);
 
     this->get_service().async_resolve(
-        this->get_implementation(), q, init.handler);
+        this->get_implementation(), q, init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -760,7 +760,7 @@
       void (asio::error_code, results_type)> init(handler);
 
     this->get_service().async_resolve(
-        this->get_implementation(), q, init.handler);
+        this->get_implementation(), q, init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -893,7 +893,7 @@
       void (asio::error_code, results_type)> init(handler);
 
     this->get_service().async_resolve(
-        this->get_implementation(), q, init.handler);
+        this->get_implementation(), q, init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
@@ -984,7 +984,7 @@
       void (asio::error_code, results_type)> init(handler);
 
     this->get_service().async_resolve(
-        this->get_implementation(), e, init.handler);
+        this->get_implementation(), e, init.completion_handler);
 
     return init.result.get();
 #endif // defined(ASIO_ENABLE_OLD_SERVICES)
diff --git a/asio/include/asio/ip/resolver_service.hpp b/asio/include/asio/ip/resolver_service.hpp
index ef1a28c..b8461b8 100644
--- a/asio/include/asio/ip/resolver_service.hpp
+++ b/asio/include/asio/ip/resolver_service.hpp
@@ -146,7 +146,7 @@
     asio::async_completion<ResolveHandler,
       void (asio::error_code, results_type)> init(handler);
 
-    service_impl_.async_resolve(impl, query, init.handler);
+    service_impl_.async_resolve(impl, query, init.completion_handler);
 
     return init.result.get();
   }
@@ -168,7 +168,7 @@
     asio::async_completion<ResolveHandler,
       void (asio::error_code, results_type)> init(handler);
 
-    service_impl_.async_resolve(impl, endpoint, init.handler);
+    service_impl_.async_resolve(impl, endpoint, init.completion_handler);
 
     return init.result.get();
   }
diff --git a/asio/include/asio/package.hpp b/asio/include/asio/package.hpp
index b8158b4..4e5e1c5 100644
--- a/asio/include/asio/package.hpp
+++ b/asio/include/asio/package.hpp
@@ -21,7 +21,6 @@
 #include "asio/async_result.hpp"
 #include "asio/detail/type_traits.hpp"
 #include "asio/detail/variadic_templates.hpp"
-#include "asio/handler_type.hpp"
 
 #include "asio/detail/push_options.hpp"
 
diff --git a/asio/include/asio/posix/descriptor.hpp b/asio/include/asio/posix/descriptor.hpp
index cc32536..28b3b9b 100644
--- a/asio/include/asio/posix/descriptor.hpp
+++ b/asio/include/asio/posix/descriptor.hpp
@@ -607,7 +607,7 @@
       void (asio::error_code)> init(handler);
 
     this->get_service().async_wait(
-        this->get_implementation(), w, init.handler);
+        this->get_implementation(), w, init.completion_handler);
 
     return init.result.get();
   }
diff --git a/asio/include/asio/posix/stream_descriptor.hpp b/asio/include/asio/posix/stream_descriptor.hpp
index 3f28ccf..3a7b689 100644
--- a/asio/include/asio/posix/stream_descriptor.hpp
+++ b/asio/include/asio/posix/stream_descriptor.hpp
@@ -226,7 +226,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     this->get_service().async_write_some(
-        this->get_implementation(), buffers, init.handler);
+        this->get_implementation(), buffers, init.completion_handler);
 
     return init.result.get();
   }
@@ -344,7 +344,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     this->get_service().async_read_some(
-        this->get_implementation(), buffers, init.handler);
+        this->get_implementation(), buffers, init.completion_handler);
 
     return init.result.get();
   }
diff --git a/asio/include/asio/posix/stream_descriptor_service.hpp b/asio/include/asio/posix/stream_descriptor_service.hpp
index ed050cc..2673fd0 100644
--- a/asio/include/asio/posix/stream_descriptor_service.hpp
+++ b/asio/include/asio/posix/stream_descriptor_service.hpp
@@ -195,7 +195,7 @@
     async_completion<WaitHandler,
       void (asio::error_code)> init(handler);
 
-    service_impl_.async_wait(impl, w, init.handler);
+    service_impl_.async_wait(impl, w, init.completion_handler);
 
     return init.result.get();
   }
@@ -219,7 +219,7 @@
     asio::async_completion<WriteHandler,
       void (asio::error_code, std::size_t)> init(handler);
 
-    service_impl_.async_write_some(impl, buffers, init.handler);
+    service_impl_.async_write_some(impl, buffers, init.completion_handler);
 
     return init.result.get();
   }
@@ -243,7 +243,7 @@
     asio::async_completion<ReadHandler,
       void (asio::error_code, std::size_t)> init(handler);
 
-    service_impl_.async_read_some(impl, buffers, init.handler);
+    service_impl_.async_read_some(impl, buffers, init.completion_handler);
 
     return init.result.get();
   }
diff --git a/asio/include/asio/raw_socket_service.hpp b/asio/include/asio/raw_socket_service.hpp
index 546218a..9d433b5 100644
--- a/asio/include/asio/raw_socket_service.hpp
+++ b/asio/include/asio/raw_socket_service.hpp
@@ -217,7 +217,7 @@
     async_completion<ConnectHandler,
       void (asio::error_code)> init(handler);
 
-    service_impl_.async_connect(impl, peer_endpoint, init.handler);
+    service_impl_.async_connect(impl, peer_endpoint, init.completion_handler);
 
     return init.result.get();
   }
@@ -312,7 +312,7 @@
     async_completion<WaitHandler,
       void (asio::error_code)> init(handler);
 
-    service_impl_.async_wait(impl, w, init.handler);
+    service_impl_.async_wait(impl, w, init.completion_handler);
 
     return init.result.get();
   }
@@ -337,7 +337,7 @@
     async_completion<WriteHandler,
       void (asio::error_code, std::size_t)> init(handler);
 
-    service_impl_.async_send(impl, buffers, flags, init.handler);
+    service_impl_.async_send(impl, buffers, flags, init.completion_handler);
 
     return init.result.get();
   }
@@ -364,7 +364,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     service_impl_.async_send_to(impl, buffers,
-        destination, flags, init.handler);
+        destination, flags, init.completion_handler);
 
     return init.result.get();
   }
@@ -390,7 +390,7 @@
     async_completion<ReadHandler,
       void (asio::error_code, std::size_t)> init(handler);
 
-    service_impl_.async_receive(impl, buffers, flags, init.handler);
+    service_impl_.async_receive(impl, buffers, flags, init.completion_handler);
 
     return init.result.get();
   }
@@ -418,7 +418,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     service_impl_.async_receive_from(impl, buffers,
-        sender_endpoint, flags, init.handler);
+        sender_endpoint, flags, init.completion_handler);
 
     return init.result.get();
   }
diff --git a/asio/include/asio/seq_packet_socket_service.hpp b/asio/include/asio/seq_packet_socket_service.hpp
index f48efd4..a79944e 100644
--- a/asio/include/asio/seq_packet_socket_service.hpp
+++ b/asio/include/asio/seq_packet_socket_service.hpp
@@ -219,7 +219,7 @@
     async_completion<ConnectHandler,
       void (asio::error_code)> init(handler);
 
-    service_impl_.async_connect(impl, peer_endpoint, init.handler);
+    service_impl_.async_connect(impl, peer_endpoint, init.completion_handler);
 
     return init.result.get();
   }
@@ -314,7 +314,7 @@
     async_completion<WaitHandler,
       void (asio::error_code)> init(handler);
 
-    service_impl_.async_wait(impl, w, init.handler);
+    service_impl_.async_wait(impl, w, init.completion_handler);
 
     return init.result.get();
   }
@@ -340,7 +340,7 @@
     async_completion<WriteHandler,
       void (asio::error_code, std::size_t)> init(handler);
 
-    service_impl_.async_send(impl, buffers, flags, init.handler);
+    service_impl_.async_send(impl, buffers, flags, init.completion_handler);
 
     return init.result.get();
   }
@@ -368,7 +368,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     service_impl_.async_receive_with_flags(impl,
-        buffers, in_flags, out_flags, init.handler);
+        buffers, in_flags, out_flags, init.completion_handler);
 
     return init.result.get();
   }
diff --git a/asio/include/asio/serial_port.hpp b/asio/include/asio/serial_port.hpp
index 0f13dc1..ee56835 100644
--- a/asio/include/asio/serial_port.hpp
+++ b/asio/include/asio/serial_port.hpp
@@ -625,7 +625,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     this->get_service().async_write_some(
-        this->get_implementation(), buffers, init.handler);
+        this->get_implementation(), buffers, init.completion_handler);
 
     return init.result.get();
   }
@@ -743,7 +743,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     this->get_service().async_read_some(
-        this->get_implementation(), buffers, init.handler);
+        this->get_implementation(), buffers, init.completion_handler);
 
     return init.result.get();
   }
diff --git a/asio/include/asio/serial_port_service.hpp b/asio/include/asio/serial_port_service.hpp
index d0f2443..b119727 100644
--- a/asio/include/asio/serial_port_service.hpp
+++ b/asio/include/asio/serial_port_service.hpp
@@ -190,7 +190,7 @@
     async_completion<WriteHandler,
       void (asio::error_code, std::size_t)> init(handler);
 
-    service_impl_.async_write_some(impl, buffers, init.handler);
+    service_impl_.async_write_some(impl, buffers, init.completion_handler);
 
     return init.result.get();
   }
@@ -214,7 +214,7 @@
     async_completion<ReadHandler,
       void (asio::error_code, std::size_t)> init(handler);
 
-    service_impl_.async_read_some(impl, buffers, init.handler);
+    service_impl_.async_read_some(impl, buffers, init.completion_handler);
 
     return init.result.get();
   }
diff --git a/asio/include/asio/signal_set.hpp b/asio/include/asio/signal_set.hpp
index aced215..1632b23 100644
--- a/asio/include/asio/signal_set.hpp
+++ b/asio/include/asio/signal_set.hpp
@@ -432,7 +432,8 @@
     async_completion<SignalHandler,
       void (asio::error_code, int)> init(handler);
 
-    this->get_service().async_wait(this->get_implementation(), init.handler);
+    this->get_service().async_wait(this->get_implementation(),
+        init.completion_handler);
 
     return init.result.get();
   }
diff --git a/asio/include/asio/signal_set_service.hpp b/asio/include/asio/signal_set_service.hpp
index 2dca96c..f90942c 100644
--- a/asio/include/asio/signal_set_service.hpp
+++ b/asio/include/asio/signal_set_service.hpp
@@ -107,7 +107,7 @@
     async_completion<SignalHandler,
       void (asio::error_code, int)> init(handler);
 
-    service_impl_.async_wait(impl, init.handler);
+    service_impl_.async_wait(impl, init.completion_handler);
 
     return init.result.get();
   }
diff --git a/asio/include/asio/socket_acceptor_service.hpp b/asio/include/asio/socket_acceptor_service.hpp
index f8eca27..3cd5f8c 100644
--- a/asio/include/asio/socket_acceptor_service.hpp
+++ b/asio/include/asio/socket_acceptor_service.hpp
@@ -264,7 +264,7 @@
     async_completion<WaitHandler,
       void (asio::error_code)> init(handler);
 
-    service_impl_.async_wait(impl, w, init.handler);
+    service_impl_.async_wait(impl, w, init.completion_handler);
 
     return init.result.get();
   }
@@ -302,7 +302,8 @@
     async_completion<AcceptHandler,
       void (asio::error_code)> init(handler);
 
-    service_impl_.async_accept(impl, peer, peer_endpoint, init.handler);
+    service_impl_.async_accept(impl,
+        peer, peer_endpoint, init.completion_handler);
 
     return init.result.get();
   }
@@ -321,7 +322,7 @@
         typename Protocol::socket)> init(handler);
 
     service_impl_.async_accept(impl,
-        peer_io_context, peer_endpoint, init.handler);
+        peer_io_context, peer_endpoint, init.completion_handler);
 
     return init.result.get();
   }
diff --git a/asio/include/asio/stream_socket_service.hpp b/asio/include/asio/stream_socket_service.hpp
index 710111c..c1dbb34 100644
--- a/asio/include/asio/stream_socket_service.hpp
+++ b/asio/include/asio/stream_socket_service.hpp
@@ -217,7 +217,7 @@
     async_completion<ConnectHandler,
       void (asio::error_code)> init(handler);
 
-    service_impl_.async_connect(impl, peer_endpoint, init.handler);
+    service_impl_.async_connect(impl, peer_endpoint, init.completion_handler);
 
     return init.result.get();
   }
@@ -312,7 +312,7 @@
     async_completion<WaitHandler,
       void (asio::error_code)> init(handler);
 
-    service_impl_.async_wait(impl, w, init.handler);
+    service_impl_.async_wait(impl, w, init.completion_handler);
 
     return init.result.get();
   }
@@ -338,7 +338,7 @@
     async_completion<WriteHandler,
       void (asio::error_code, std::size_t)> init(handler);
 
-    service_impl_.async_send(impl, buffers, flags, init.handler);
+    service_impl_.async_send(impl, buffers, flags, init.completion_handler);
 
     return init.result.get();
   }
@@ -364,7 +364,7 @@
     async_completion<ReadHandler,
       void (asio::error_code, std::size_t)> init(handler);
 
-    service_impl_.async_receive(impl, buffers, flags, init.handler);
+    service_impl_.async_receive(impl, buffers, flags, init.completion_handler);
 
     return init.result.get();
   }
diff --git a/asio/include/asio/waitable_timer_service.hpp b/asio/include/asio/waitable_timer_service.hpp
index 0e403e5..470d176 100644
--- a/asio/include/asio/waitable_timer_service.hpp
+++ b/asio/include/asio/waitable_timer_service.hpp
@@ -185,7 +185,7 @@
     async_completion<WaitHandler,
       void (asio::error_code)> init(handler);
 
-    service_impl_.async_wait(impl, init.handler);
+    service_impl_.async_wait(impl, init.completion_handler);
 
     return init.result.get();
   }
diff --git a/asio/include/asio/windows/object_handle.hpp b/asio/include/asio/windows/object_handle.hpp
index 5efd568..c02e35f 100644
--- a/asio/include/asio/windows/object_handle.hpp
+++ b/asio/include/asio/windows/object_handle.hpp
@@ -357,7 +357,8 @@
     asio::async_completion<WaitHandler,
       void (asio::error_code)> init(handler);
 
-    this->get_service().async_wait(this->get_implementation(), init.handler);
+    this->get_service().async_wait(this->get_implementation(),
+        init.completion_handler);
 
     return init.result.get();
   }
diff --git a/asio/include/asio/windows/object_handle_service.hpp b/asio/include/asio/windows/object_handle_service.hpp
index 3db6732..fd78ac9 100644
--- a/asio/include/asio/windows/object_handle_service.hpp
+++ b/asio/include/asio/windows/object_handle_service.hpp
@@ -151,7 +151,7 @@
     asio::async_completion<WaitHandler,
       void (asio::error_code)> init(handler);
 
-    service_impl_.async_wait(impl, init.handler);
+    service_impl_.async_wait(impl, init.completion_handler);
 
     return init.result.get();
   }
diff --git a/asio/include/asio/windows/random_access_handle.hpp b/asio/include/asio/windows/random_access_handle.hpp
index b57e80c..07e2c9d 100644
--- a/asio/include/asio/windows/random_access_handle.hpp
+++ b/asio/include/asio/windows/random_access_handle.hpp
@@ -234,7 +234,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     this->get_service().async_write_some_at(this->get_implementation(),
-        offset, buffers, init.handler);
+        offset, buffers, init.completion_handler);
 
     return init.result.get();
   }
@@ -360,7 +360,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     this->get_service().async_read_some_at(this->get_implementation(),
-        offset, buffers, init.handler);
+        offset, buffers, init.completion_handler);
 
     return init.result.get();
   }
diff --git a/asio/include/asio/windows/random_access_handle_service.hpp b/asio/include/asio/windows/random_access_handle_service.hpp
index 2d57ee1..1eb6eb0 100644
--- a/asio/include/asio/windows/random_access_handle_service.hpp
+++ b/asio/include/asio/windows/random_access_handle_service.hpp
@@ -156,7 +156,8 @@
     asio::async_completion<WriteHandler,
       void (asio::error_code, std::size_t)> init(handler);
 
-    service_impl_.async_write_some_at(impl, offset, buffers, init.handler);
+    service_impl_.async_write_some_at(impl,
+        offset, buffers, init.completion_handler);
 
     return init.result.get();
   }
@@ -180,7 +181,8 @@
     asio::async_completion<ReadHandler,
       void (asio::error_code, std::size_t)> init(handler);
 
-    service_impl_.async_read_some_at(impl, offset, buffers, init.handler);
+    service_impl_.async_read_some_at(impl,
+        offset, buffers, init.completion_handler);
 
     return init.result.get();
   }
diff --git a/asio/include/asio/windows/stream_handle.hpp b/asio/include/asio/windows/stream_handle.hpp
index a150fce..54e0bcd 100644
--- a/asio/include/asio/windows/stream_handle.hpp
+++ b/asio/include/asio/windows/stream_handle.hpp
@@ -226,7 +226,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     this->get_service().async_write_some(
-        this->get_implementation(), buffers, init.handler);
+        this->get_implementation(), buffers, init.completion_handler);
 
     return init.result.get();
   }
@@ -344,7 +344,7 @@
       void (asio::error_code, std::size_t)> init(handler);
 
     this->get_service().async_read_some(
-        this->get_implementation(), buffers, init.handler);
+        this->get_implementation(), buffers, init.completion_handler);
 
     return init.result.get();
   }
diff --git a/asio/include/asio/windows/stream_handle_service.hpp b/asio/include/asio/windows/stream_handle_service.hpp
index 9f4cf68..18857aa 100644
--- a/asio/include/asio/windows/stream_handle_service.hpp
+++ b/asio/include/asio/windows/stream_handle_service.hpp
@@ -154,7 +154,7 @@
     asio::async_completion<WriteHandler,
       void (asio::error_code, std::size_t)> init(handler);
 
-    service_impl_.async_write_some(impl, buffers, init.handler);
+    service_impl_.async_write_some(impl, buffers, init.completion_handler);
 
     return init.result.get();
   }
@@ -178,7 +178,7 @@
     asio::async_completion<ReadHandler,
       void (asio::error_code, std::size_t)> init(handler);
 
-    service_impl_.async_read_some(impl, buffers, init.handler);
+    service_impl_.async_read_some(impl, buffers, init.completion_handler);
 
     return init.result.get();
   }
diff --git a/asio/src/tests/Makefile.am b/asio/src/tests/Makefile.am
index 81ac613..b7ac755 100644
--- a/asio/src/tests/Makefile.am
+++ b/asio/src/tests/Makefile.am
@@ -366,6 +366,7 @@
 	latency/allocator.hpp \
 	performance/handler_allocator.hpp \
 	unit/archetypes/async_result.hpp \
+	unit/archetypes/deprecated_async_result.hpp \
 	unit/archetypes/gettable_socket_option.hpp \
 	unit/archetypes/io_control_command.hpp \
 	unit/archetypes/settable_socket_option.hpp
diff --git a/asio/src/tests/unit/archetypes/async_result.hpp b/asio/src/tests/unit/archetypes/async_result.hpp
index 96cf76a..d060e8a 100644
--- a/asio/src/tests/unit/archetypes/async_result.hpp
+++ b/asio/src/tests/unit/archetypes/async_result.hpp
@@ -12,7 +12,6 @@
 #define ARCHETYPES_ASYNC_RESULT_HPP
 
 #include <asio/async_result.hpp>
-#include <asio/handler_type.hpp>
 
 namespace archetypes {
 
@@ -48,28 +47,30 @@
 namespace asio {
 
 template <typename Signature>
-struct handler_type<archetypes::lazy_handler, Signature>
-{
-  typedef archetypes::concrete_handler type;
-};
-
-template <>
-class async_result<archetypes::concrete_handler>
+class async_result<archetypes::lazy_handler, Signature>
 {
 public:
+  // The concrete completion handler type.
+  typedef archetypes::concrete_handler completion_handler_type;
+
   // The return type of the initiating function.
-  typedef int type;
+  typedef int return_type;
 
   // Construct an async_result from a given handler.
-  explicit async_result(archetypes::concrete_handler&)
+  explicit async_result(completion_handler_type&)
   {
   }
 
   // Obtain the value to be returned from the initiating function.
-  type get()
+  return_type get()
   {
     return 42;
   }
+
+private:
+  // Disallow copying and assignment.
+  async_result(const async_result&) ASIO_DELETED;
+  async_result& operator=(const async_result&) ASIO_DELETED;
 };
 
 } // namespace asio
diff --git a/asio/src/tests/unit/archetypes/deprecated_async_result.hpp b/asio/src/tests/unit/archetypes/deprecated_async_result.hpp
new file mode 100644
index 0000000..fd9c043
--- /dev/null
+++ b/asio/src/tests/unit/archetypes/deprecated_async_result.hpp
@@ -0,0 +1,82 @@
+//
+// async_result.hpp
+// ~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#ifndef ARCHETYPES_DEPRECATED_ASYNC_RESULT_HPP
+#define ARCHETYPES_DEPRECATED_ASYNC_RESULT_HPP
+
+#include <asio/async_result.hpp>
+
+#if !defined(ASIO_NO_DEPRECATED)
+
+#include <asio/handler_type.hpp>
+
+namespace archetypes {
+
+struct deprecated_lazy_handler
+{
+};
+
+struct deprecated_concrete_handler
+{
+  deprecated_concrete_handler(deprecated_lazy_handler)
+  {
+  }
+
+  template <typename Arg1>
+  void operator()(Arg1)
+  {
+  }
+
+  template <typename Arg1, typename Arg2>
+  void operator()(Arg1, Arg2)
+  {
+  }
+
+#if defined(ASIO_HAS_MOVE)
+  deprecated_concrete_handler(deprecated_concrete_handler&&) {}
+private:
+  deprecated_concrete_handler(const deprecated_concrete_handler&);
+#endif // defined(ASIO_HAS_MOVE)
+};
+
+} // namespace archetypes
+
+namespace asio {
+
+template <typename Signature>
+struct handler_type<archetypes::deprecated_lazy_handler, Signature>
+{
+  typedef archetypes::deprecated_concrete_handler type;
+};
+
+template <>
+class async_result<archetypes::deprecated_concrete_handler>
+{
+public:
+  // The return type of the initiating function.
+  typedef double type;
+
+  // Construct an async_result from a given handler.
+  explicit async_result(archetypes::deprecated_concrete_handler&)
+  {
+  }
+
+  // Obtain the value to be returned from the initiating function.
+  type get()
+  {
+    return 42;
+  }
+};
+
+} // namespace asio
+
+#endif // !defined(ASIO_NO_DEPRECATED)
+
+#endif // ARCHETYPES_DEPRECATED_ASYNC_RESULT_HPP
diff --git a/asio/src/tests/unit/ip/icmp.cpp b/asio/src/tests/unit/ip/icmp.cpp
index 9d27fac..77606d1 100644
--- a/asio/src/tests/unit/ip/icmp.cpp
+++ b/asio/src/tests/unit/ip/icmp.cpp
@@ -20,8 +20,9 @@
 #include "asio/io_context.hpp"
 #include "asio/placeholders.hpp"
 #include "../unit_test.hpp"
-#include "../archetypes/gettable_socket_option.hpp"
 #include "../archetypes/async_result.hpp"
+#include "../archetypes/deprecated_async_result.hpp"
+#include "../archetypes/gettable_socket_option.hpp"
 #include "../archetypes/io_control_command.hpp"
 #include "../archetypes/settable_socket_option.hpp"
 
@@ -86,6 +87,9 @@
     archetypes::gettable_socket_option<double> gettable_socket_option3;
     archetypes::io_control_command io_control_command;
     archetypes::lazy_handler lazy;
+#if !defined(ASIO_NO_DEPRECATED)
+    archetypes::deprecated_lazy_handler dlazy;
+#endif // !defined(ASIO_NO_DEPRECATED)
     asio::error_code ec;
 
     // basic_datagram_socket constructors.
@@ -182,6 +186,14 @@
     (void)i1;
     int i2 = socket1.async_connect(ip::icmp::endpoint(ip::icmp::v6(), 0), lazy);
     (void)i2;
+#if !defined(ASIO_NO_DEPRECATED)
+    double d1 = socket1.async_connect(
+        ip::icmp::endpoint(ip::icmp::v4(), 0), dlazy);
+    (void)d1;
+    double d2 = socket1.async_connect(
+        ip::icmp::endpoint(ip::icmp::v6(), 0), dlazy);
+    (void)d2;
+#endif // !defined(ASIO_NO_DEPRECATED)
 
     socket1.set_option(settable_socket_option1);
     socket1.set_option(settable_socket_option1, ec);
@@ -249,6 +261,21 @@
     (void)i7;
     int i8 = socket1.async_send(null_buffers(), in_flags, lazy);
     (void)i8;
+#if !defined(ASIO_NO_DEPRECATED)
+    double d3 = socket1.async_send(buffer(mutable_char_buffer), dlazy);
+    (void)d3;
+    double d4 = socket1.async_send(buffer(const_char_buffer), dlazy);
+    (void)d4;
+    double d5 = socket1.async_send(null_buffers(), dlazy);
+    (void)d5;
+    double d6 = socket1.async_send(
+        buffer(mutable_char_buffer), in_flags, dlazy);
+    (void)d6;
+    double d7 = socket1.async_send(buffer(const_char_buffer), in_flags, dlazy);
+    (void)d7;
+    double d8 = socket1.async_send(null_buffers(), in_flags, dlazy);
+    (void)d8;
+#endif // !defined(ASIO_NO_DEPRECATED)
 
     socket1.send_to(buffer(mutable_char_buffer),
         ip::icmp::endpoint(ip::icmp::v4(), 0));
@@ -347,6 +374,44 @@
     int i20 = socket1.async_send_to(null_buffers(),
         ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, lazy);
     (void)i20;
+#if !defined(ASIO_NO_DEPRECATED)
+    double d9 = socket1.async_send_to(buffer(mutable_char_buffer),
+        ip::icmp::endpoint(ip::icmp::v4(), 0), dlazy);
+    (void)d9;
+    double d10 = socket1.async_send_to(buffer(mutable_char_buffer),
+        ip::icmp::endpoint(ip::icmp::v6(), 0), dlazy);
+    (void)d10;
+    double d11 = socket1.async_send_to(buffer(const_char_buffer),
+        ip::icmp::endpoint(ip::icmp::v4(), 0), dlazy);
+    (void)d11;
+    double d12 = socket1.async_send_to(buffer(const_char_buffer),
+        ip::icmp::endpoint(ip::icmp::v6(), 0), dlazy);
+    (void)d12;
+    double d13 = socket1.async_send_to(null_buffers(),
+        ip::icmp::endpoint(ip::icmp::v4(), 0), dlazy);
+    (void)d13;
+    double d14 = socket1.async_send_to(null_buffers(),
+        ip::icmp::endpoint(ip::icmp::v6(), 0), dlazy);
+    (void)d14;
+    double d15 = socket1.async_send_to(buffer(mutable_char_buffer),
+        ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, dlazy);
+    (void)d15;
+    double d16 = socket1.async_send_to(buffer(mutable_char_buffer),
+        ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, dlazy);
+    (void)d16;
+    double d17 = socket1.async_send_to(buffer(const_char_buffer),
+        ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, dlazy);
+    (void)d17;
+    double d18 = socket1.async_send_to(buffer(const_char_buffer),
+        ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, dlazy);
+    (void)d18;
+    double d19 = socket1.async_send_to(null_buffers(),
+        ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, dlazy);
+    (void)d19;
+    double d20 = socket1.async_send_to(null_buffers(),
+        ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, dlazy);
+    (void)d20;
+#endif // !defined(ASIO_NO_DEPRECATED)
 
     socket1.receive(buffer(mutable_char_buffer));
     socket1.receive(null_buffers());
@@ -369,6 +434,17 @@
     (void)i23;
     int i24 = socket1.async_receive(null_buffers(), in_flags, lazy);
     (void)i24;
+#if !defined(ASIO_NO_DEPRECATED)
+    double d21 = socket1.async_receive(buffer(mutable_char_buffer), dlazy);
+    (void)d21;
+    double d22 = socket1.async_receive(null_buffers(), dlazy);
+    (void)d22;
+    double d23 = socket1.async_receive(buffer(mutable_char_buffer),
+        in_flags, dlazy);
+    (void)d23;
+    double d24 = socket1.async_receive(null_buffers(), in_flags, dlazy);
+    (void)d24;
+#endif // !defined(ASIO_NO_DEPRECATED)
 
     ip::icmp::endpoint endpoint;
     socket1.receive_from(buffer(mutable_char_buffer), endpoint);
@@ -398,6 +474,20 @@
     int i28 = socket1.async_receive_from(null_buffers(),
         endpoint, in_flags, lazy);
     (void)i28;
+#if !defined(ASIO_NO_DEPRECATED)
+    double d25 = socket1.async_receive_from(buffer(mutable_char_buffer),
+        endpoint, dlazy);
+    (void)d25;
+    double d26 = socket1.async_receive_from(null_buffers(),
+        endpoint, dlazy);
+    (void)d26;
+    double d27 = socket1.async_receive_from(buffer(mutable_char_buffer),
+        endpoint, in_flags, dlazy);
+    (void)d27;
+    double d28 = socket1.async_receive_from(null_buffers(),
+        endpoint, in_flags, dlazy);
+    (void)d28;
+#endif // !defined(ASIO_NO_DEPRECATED)
   }
   catch (std::exception&)
   {
@@ -436,6 +526,9 @@
   {
     io_context ioc;
     archetypes::lazy_handler lazy;
+#if !defined(ASIO_NO_DEPRECATED)
+    archetypes::deprecated_lazy_handler dlazy;
+#endif // !defined(ASIO_NO_DEPRECATED)
     asio::error_code ec;
     ip::icmp::resolver::query q(ip::icmp::v4(), "localhost", "0");
     ip::icmp::endpoint e(ip::address_v4::loopback(), 0);
@@ -530,6 +623,34 @@
     resolver.async_resolve(e, resolve_handler());
     int i6 = resolver.async_resolve(e, lazy);
     (void)i6;
+
+#if !defined(ASIO_NO_DEPRECATED)
+    resolver.async_resolve(q, resolve_handler());
+    double d1 = resolver.async_resolve(q, dlazy);
+    (void)d1;
+
+    resolver.async_resolve(q, resolve_handler());
+    double d2 = resolver.async_resolve("", "", dlazy);
+    (void)d2;
+
+    resolver.async_resolve(q, resolve_handler());
+    double d3 = resolver.async_resolve("", "",
+        ip::icmp::resolver::flags(), dlazy);
+    (void)d3;
+
+    resolver.async_resolve(q, resolve_handler());
+    double d4 = resolver.async_resolve(ip::icmp::v4(), "", "", dlazy);
+    (void)d4;
+
+    resolver.async_resolve(q, resolve_handler());
+    double d5 = resolver.async_resolve(ip::icmp::v4(),
+        "", "", ip::icmp::resolver::flags(), dlazy);
+    (void)d5;
+
+    resolver.async_resolve(e, resolve_handler());
+    double d6 = resolver.async_resolve(e, dlazy);
+    (void)d6;
+#endif // !defined(ASIO_NO_DEPRECATED)
   }
   catch (std::exception&)
   {
diff --git a/asio/src/tests/unit/ip/tcp.cpp b/asio/src/tests/unit/ip/tcp.cpp
index a3165df..4b2f49d 100644
--- a/asio/src/tests/unit/ip/tcp.cpp
+++ b/asio/src/tests/unit/ip/tcp.cpp
@@ -24,8 +24,9 @@
 #include "asio/read.hpp"
 #include "asio/write.hpp"
 #include "../unit_test.hpp"
-#include "../archetypes/gettable_socket_option.hpp"
 #include "../archetypes/async_result.hpp"
+#include "../archetypes/deprecated_async_result.hpp"
+#include "../archetypes/gettable_socket_option.hpp"
 #include "../archetypes/io_control_command.hpp"
 #include "../archetypes/settable_socket_option.hpp"
 
@@ -234,6 +235,9 @@
     archetypes::gettable_socket_option<double> gettable_socket_option3;
     archetypes::io_control_command io_control_command;
     archetypes::lazy_handler lazy;
+#if !defined(ASIO_NO_DEPRECATED)
+    archetypes::deprecated_lazy_handler dlazy;
+#endif // !defined(ASIO_NO_DEPRECATED)
     asio::error_code ec;
 
     // basic_stream_socket constructors.
@@ -333,6 +337,14 @@
     (void)i1;
     int i2 = socket1.async_connect(ip::tcp::endpoint(ip::tcp::v6(), 0), lazy);
     (void)i2;
+#if !defined(ASIO_NO_DEPRECATED)
+    double d1 = socket1.async_connect(
+        ip::tcp::endpoint(ip::tcp::v4(), 0), dlazy);
+    (void)d1;
+    double d2 = socket1.async_connect(
+        ip::tcp::endpoint(ip::tcp::v6(), 0), dlazy);
+    (void)d2;
+#endif // !defined(ASIO_NO_DEPRECATED)
 
     socket1.set_option(settable_socket_option1);
     socket1.set_option(settable_socket_option1, ec);
@@ -376,6 +388,10 @@
     socket1.async_wait(socket_base::wait_read, wait_handler());
     int i3 = socket1.async_wait(socket_base::wait_write, lazy);
     (void)i3;
+#if !defined(ASIO_NO_DEPRECATED)
+    double d3 = socket1.async_wait(socket_base::wait_write, dlazy);
+    (void)d3;
+#endif // !defined(ASIO_NO_DEPRECATED)
 
     // basic_stream_socket functions.
 
@@ -425,6 +441,29 @@
     (void)i12;
     int i13 = socket1.async_send(null_buffers(), in_flags, lazy);
     (void)i13;
+#if !defined(ASIO_NO_DEPRECATED)
+    double d4 = socket1.async_send(buffer(mutable_char_buffer), dlazy);
+    (void)d4;
+    double d5 = socket1.async_send(buffer(const_char_buffer), dlazy);
+    (void)d5;
+    double d6 = socket1.async_send(mutable_buffers, dlazy);
+    (void)d6;
+    double d7 = socket1.async_send(const_buffers, dlazy);
+    (void)d7;
+    double d8 = socket1.async_send(null_buffers(), dlazy);
+    (void)d8;
+    double d9 = socket1.async_send(
+        buffer(mutable_char_buffer), in_flags, dlazy);
+    (void)d9;
+    double d10 = socket1.async_send(buffer(const_char_buffer), in_flags, dlazy);
+    (void)d10;
+    double d11 = socket1.async_send(mutable_buffers, in_flags, dlazy);
+    (void)d11;
+    double d12 = socket1.async_send(const_buffers, in_flags, dlazy);
+    (void)d12;
+    double d13 = socket1.async_send(null_buffers(), in_flags, dlazy);
+    (void)d13;
+#endif // !defined(ASIO_NO_DEPRECATED)
 
     socket1.receive(buffer(mutable_char_buffer));
     socket1.receive(mutable_buffers);
@@ -456,6 +495,21 @@
     (void)i18;
     int i19 = socket1.async_receive(null_buffers(), in_flags, lazy);
     (void)i19;
+#if !defined(ASIO_NO_DEPRECATED)
+    double d14 = socket1.async_receive(buffer(mutable_char_buffer), dlazy);
+    (void)d14;
+    double d15 = socket1.async_receive(mutable_buffers, dlazy);
+    (void)d15;
+    double d16 = socket1.async_receive(null_buffers(), dlazy);
+    (void)d16;
+    double d17 = socket1.async_receive(buffer(mutable_char_buffer), in_flags,
+        dlazy);
+    (void)d17;
+    double d18 = socket1.async_receive(mutable_buffers, in_flags, dlazy);
+    (void)d18;
+    double d19 = socket1.async_receive(null_buffers(), in_flags, dlazy);
+    (void)d19;
+#endif // !defined(ASIO_NO_DEPRECATED)
 
     socket1.write_some(buffer(mutable_char_buffer));
     socket1.write_some(buffer(const_char_buffer));
@@ -483,6 +537,18 @@
     (void)i23;
     int i24 = socket1.async_write_some(null_buffers(), lazy);
     (void)i24;
+#if !defined(ASIO_NO_DEPRECATED)
+    double d20 = socket1.async_write_some(buffer(mutable_char_buffer), dlazy);
+    (void)d20;
+    double d21 = socket1.async_write_some(buffer(const_char_buffer), dlazy);
+    (void)d21;
+    double d22 = socket1.async_write_some(mutable_buffers, dlazy);
+    (void)d22;
+    double d23 = socket1.async_write_some(const_buffers, dlazy);
+    (void)d23;
+    double d24 = socket1.async_write_some(null_buffers(), dlazy);
+    (void)d24;
+#endif // !defined(ASIO_NO_DEPRECATED)
 
     socket1.read_some(buffer(mutable_char_buffer));
     socket1.read_some(mutable_buffers);
@@ -500,6 +566,14 @@
     (void)i26;
     int i27 = socket1.async_read_some(null_buffers(), lazy);
     (void)i27;
+#if !defined(ASIO_NO_DEPRECATED)
+    double d25 = socket1.async_read_some(buffer(mutable_char_buffer), dlazy);
+    (void)d25;
+    double d26 = socket1.async_read_some(mutable_buffers, dlazy);
+    (void)d26;
+    double d27 = socket1.async_read_some(null_buffers(), dlazy);
+    (void)d27;
+#endif // !defined(ASIO_NO_DEPRECATED)
   }
   catch (std::exception&)
   {
@@ -732,6 +806,9 @@
     archetypes::gettable_socket_option<double> gettable_socket_option3;
     archetypes::io_control_command io_control_command;
     archetypes::lazy_handler lazy;
+#if !defined(ASIO_NO_DEPRECATED)
+    archetypes::deprecated_lazy_handler dlazy;
+#endif // !defined(ASIO_NO_DEPRECATED)
     asio::error_code ec;
 
     // basic_socket_acceptor constructors.
@@ -833,6 +910,10 @@
     acceptor1.async_wait(socket_base::wait_read, wait_handler());
     int i1 = acceptor1.async_wait(socket_base::wait_write, lazy);
     (void)i1;
+#if !defined(ASIO_NO_DEPRECATED)
+    double d1 = acceptor1.async_wait(socket_base::wait_write, dlazy);
+    (void)d1;
+#endif // !defined(ASIO_NO_DEPRECATED)
 
     acceptor1.accept(peer_socket);
     acceptor1.accept(peer_socket, ec);
@@ -853,6 +934,12 @@
     (void)i2;
     int i3 = acceptor1.async_accept(peer_socket, peer_endpoint, lazy);
     (void)i3;
+#if !defined(ASIO_NO_DEPRECATED)
+    double d2 = acceptor1.async_accept(peer_socket, dlazy);
+    (void)d2;
+    double d3 = acceptor1.async_accept(peer_socket, peer_endpoint, dlazy);
+    (void)d3;
+#endif // !defined(ASIO_NO_DEPRECATED)
 
 #if defined(ASIO_HAS_MOVE)
     acceptor1.async_accept(move_accept_handler());
@@ -977,6 +1064,9 @@
   {
     io_context ioc;
     archetypes::lazy_handler lazy;
+#if !defined(ASIO_NO_DEPRECATED)
+    archetypes::deprecated_lazy_handler dlazy;
+#endif // !defined(ASIO_NO_DEPRECATED)
     asio::error_code ec;
     ip::tcp::resolver::query q(ip::tcp::v4(), "localhost", "0");
     ip::tcp::endpoint e(ip::address_v4::loopback(), 0);
@@ -1071,6 +1161,34 @@
     resolver.async_resolve(e, resolve_handler());
     int i6 = resolver.async_resolve(e, lazy);
     (void)i6;
+
+#if !defined(ASIO_NO_DEPRECATED)
+    resolver.async_resolve(q, resolve_handler());
+    double d1 = resolver.async_resolve(q, dlazy);
+    (void)d1;
+
+    resolver.async_resolve(q, resolve_handler());
+    double d2 = resolver.async_resolve("", "", dlazy);
+    (void)d2;
+
+    resolver.async_resolve(q, resolve_handler());
+    double d3 = resolver.async_resolve("", "",
+        ip::tcp::resolver::flags(), dlazy);
+    (void)d3;
+
+    resolver.async_resolve(q, resolve_handler());
+    double d4 = resolver.async_resolve(ip::tcp::v4(), "", "", dlazy);
+    (void)d4;
+
+    resolver.async_resolve(q, resolve_handler());
+    double d5 = resolver.async_resolve(ip::tcp::v4(),
+        "", "", ip::tcp::resolver::flags(), dlazy);
+    (void)d5;
+
+    resolver.async_resolve(e, resolve_handler());
+    double d6 = resolver.async_resolve(e, dlazy);
+    (void)d6;
+#endif // !defined(ASIO_NO_DEPRECATED)
   }
   catch (std::exception&)
   {
diff --git a/asio/src/tests/unit/ip/udp.cpp b/asio/src/tests/unit/ip/udp.cpp
index f8417d6..8436d3d 100644
--- a/asio/src/tests/unit/ip/udp.cpp
+++ b/asio/src/tests/unit/ip/udp.cpp
@@ -19,8 +19,9 @@
 #include <cstring>
 #include "asio/io_context.hpp"
 #include "../unit_test.hpp"
-#include "../archetypes/gettable_socket_option.hpp"
 #include "../archetypes/async_result.hpp"
+#include "../archetypes/deprecated_async_result.hpp"
+#include "../archetypes/gettable_socket_option.hpp"
 #include "../archetypes/io_control_command.hpp"
 #include "../archetypes/settable_socket_option.hpp"
 
@@ -102,6 +103,9 @@
     archetypes::gettable_socket_option<double> gettable_socket_option3;
     archetypes::io_control_command io_control_command;
     archetypes::lazy_handler lazy;
+#if !defined(ASIO_NO_DEPRECATED)
+    archetypes::deprecated_lazy_handler dlazy;
+#endif // !defined(ASIO_NO_DEPRECATED)
     asio::error_code ec;
 
     // basic_datagram_socket constructors.
@@ -201,6 +205,14 @@
     (void)i1;
     int i2 = socket1.async_connect(ip::udp::endpoint(ip::udp::v6(), 0), lazy);
     (void)i2;
+#if !defined(ASIO_NO_DEPRECATED)
+    double d1 = socket1.async_connect(
+        ip::udp::endpoint(ip::udp::v4(), 0), dlazy);
+    (void)d1;
+    double d2 = socket1.async_connect(
+        ip::udp::endpoint(ip::udp::v6(), 0), dlazy);
+    (void)d2;
+#endif // !defined(ASIO_NO_DEPRECATED)
 
     socket1.set_option(settable_socket_option1);
     socket1.set_option(settable_socket_option1, ec);
@@ -244,6 +256,10 @@
     socket1.async_wait(socket_base::wait_read, wait_handler());
     int i3 = socket1.async_wait(socket_base::wait_write, lazy);
     (void)i3;
+#if !defined(ASIO_NO_DEPRECATED)
+    double d3 = socket1.async_wait(socket_base::wait_write, dlazy);
+    (void)d3;
+#endif // !defined(ASIO_NO_DEPRECATED)
 
     // basic_datagram_socket functions.
 
@@ -275,6 +291,21 @@
     (void)i8;
     int i9 = socket1.async_send(null_buffers(), in_flags, lazy);
     (void)i9;
+#if !defined(ASIO_NO_DEPRECATED)
+    double d4 = socket1.async_send(buffer(mutable_char_buffer), dlazy);
+    (void)d4;
+    double d5 = socket1.async_send(buffer(const_char_buffer), dlazy);
+    (void)d5;
+    double d6 = socket1.async_send(null_buffers(), dlazy);
+    (void)d6;
+    double d7 = socket1.async_send(
+        buffer(mutable_char_buffer), in_flags, dlazy);
+    (void)d7;
+    double d8 = socket1.async_send(buffer(const_char_buffer), in_flags, dlazy);
+    (void)d8;
+    double d9 = socket1.async_send(null_buffers(), in_flags, dlazy);
+    (void)d9;
+#endif // !defined(ASIO_NO_DEPRECATED)
 
     socket1.send_to(buffer(mutable_char_buffer),
         ip::udp::endpoint(ip::udp::v4(), 0));
@@ -373,6 +404,44 @@
     int i21 = socket1.async_send_to(null_buffers(),
         ip::udp::endpoint(ip::udp::v6(), 0), in_flags, lazy);
     (void)i21;
+#if !defined(ASIO_NO_DEPRECATED)
+    double d10 = socket1.async_send_to(buffer(mutable_char_buffer),
+        ip::udp::endpoint(ip::udp::v4(), 0), dlazy);
+    (void)d10;
+    double d11 = socket1.async_send_to(buffer(mutable_char_buffer),
+        ip::udp::endpoint(ip::udp::v6(), 0), dlazy);
+    (void)d11;
+    double d12 = socket1.async_send_to(buffer(const_char_buffer),
+        ip::udp::endpoint(ip::udp::v4(), 0), dlazy);
+    (void)d12;
+    double d13 = socket1.async_send_to(buffer(const_char_buffer),
+        ip::udp::endpoint(ip::udp::v6(), 0), dlazy);
+    (void)d13;
+    double d14 = socket1.async_send_to(null_buffers(),
+        ip::udp::endpoint(ip::udp::v4(), 0), dlazy);
+    (void)d14;
+    double d15 = socket1.async_send_to(null_buffers(),
+        ip::udp::endpoint(ip::udp::v6(), 0), dlazy);
+    (void)d15;
+    double d16 = socket1.async_send_to(buffer(mutable_char_buffer),
+        ip::udp::endpoint(ip::udp::v4(), 0), in_flags, dlazy);
+    (void)d16;
+    double d17 = socket1.async_send_to(buffer(mutable_char_buffer),
+        ip::udp::endpoint(ip::udp::v6(), 0), in_flags, dlazy);
+    (void)d17;
+    double d18 = socket1.async_send_to(buffer(const_char_buffer),
+        ip::udp::endpoint(ip::udp::v4(), 0), in_flags, dlazy);
+    (void)d18;
+    double d19 = socket1.async_send_to(buffer(const_char_buffer),
+        ip::udp::endpoint(ip::udp::v6(), 0), in_flags, dlazy);
+    (void)d19;
+    double d20 = socket1.async_send_to(null_buffers(),
+        ip::udp::endpoint(ip::udp::v4(), 0), in_flags, dlazy);
+    (void)d20;
+    double d21 = socket1.async_send_to(null_buffers(),
+        ip::udp::endpoint(ip::udp::v6(), 0), in_flags, dlazy);
+    (void)d21;
+#endif // !defined(ASIO_NO_DEPRECATED)
 
     socket1.receive(buffer(mutable_char_buffer));
     socket1.receive(null_buffers());
@@ -395,6 +464,17 @@
     (void)i24;
     int i25 = socket1.async_receive(null_buffers(), in_flags, lazy);
     (void)i25;
+#if !defined(ASIO_NO_DEPRECATED)
+    double d22 = socket1.async_receive(buffer(mutable_char_buffer), dlazy);
+    (void)d22;
+    double d23 = socket1.async_receive(null_buffers(), dlazy);
+    (void)d23;
+    double d24 = socket1.async_receive(buffer(mutable_char_buffer),
+        in_flags, dlazy);
+    (void)d24;
+    double d25 = socket1.async_receive(null_buffers(), in_flags, dlazy);
+    (void)d25;
+#endif // !defined(ASIO_NO_DEPRECATED)
 
     ip::udp::endpoint endpoint;
     socket1.receive_from(buffer(mutable_char_buffer), endpoint);
@@ -424,6 +504,20 @@
     int i29 = socket1.async_receive_from(null_buffers(),
         endpoint, in_flags, lazy);
     (void)i29;
+#if !defined(ASIO_NO_DEPRECATED)
+    double d26 = socket1.async_receive_from(buffer(mutable_char_buffer),
+        endpoint, dlazy);
+    (void)d26;
+    double d27 = socket1.async_receive_from(null_buffers(),
+        endpoint, dlazy);
+    (void)d27;
+    double d28 = socket1.async_receive_from(buffer(mutable_char_buffer),
+        endpoint, in_flags, dlazy);
+    (void)d28;
+    double d29 = socket1.async_receive_from(null_buffers(),
+        endpoint, in_flags, dlazy);
+    (void)d29;
+#endif // !defined(ASIO_NO_DEPRECATED)
   }
   catch (std::exception&)
   {
@@ -533,6 +627,9 @@
   {
     io_context ioc;
     archetypes::lazy_handler lazy;
+#if !defined(ASIO_NO_DEPRECATED)
+    archetypes::deprecated_lazy_handler dlazy;
+#endif // !defined(ASIO_NO_DEPRECATED)
     asio::error_code ec;
     ip::udp::resolver::query q(ip::udp::v4(), "localhost", "0");
     ip::udp::endpoint e(ip::address_v4::loopback(), 0);
@@ -627,6 +724,34 @@
     resolver.async_resolve(e, resolve_handler());
     int i6 = resolver.async_resolve(e, lazy);
     (void)i6;
+
+#if !defined(ASIO_NO_DEPRECATED)
+    resolver.async_resolve(q, resolve_handler());
+    double d1 = resolver.async_resolve(q, dlazy);
+    (void)d1;
+
+    resolver.async_resolve(q, resolve_handler());
+    double d2 = resolver.async_resolve("", "", dlazy);
+    (void)d2;
+
+    resolver.async_resolve(q, resolve_handler());
+    double d3 = resolver.async_resolve("", "",
+        ip::udp::resolver::flags(), dlazy);
+    (void)d3;
+
+    resolver.async_resolve(q, resolve_handler());
+    double d4 = resolver.async_resolve(ip::udp::v4(), "", "", dlazy);
+    (void)d4;
+
+    resolver.async_resolve(q, resolve_handler());
+    double d5 = resolver.async_resolve(ip::udp::v4(),
+        "", "", ip::udp::resolver::flags(), dlazy);
+    (void)d5;
+
+    resolver.async_resolve(e, resolve_handler());
+    double d6 = resolver.async_resolve(e, dlazy);
+    (void)d6;
+#endif // !defined(ASIO_NO_DEPRECATED)
   }
   catch (std::exception&)
   {