5 // Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_ASIO_IMPL_DETACHED_HPP
12 #define BOOST_ASIO_IMPL_DETACHED_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/config.hpp>
19 #include <boost/asio/async_result.hpp>
20 #include <boost/asio/detail/variadic_templates.hpp>
22 #include <boost/asio/detail/push_options.hpp>
28 // Class to adapt a detached_t as a completion handler.
29 class detached_handler
32 typedef void result_type;
34 detached_handler(detached_t)
38 #if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
40 template <typename... Args>
41 void operator()(Args...)
45 #else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
51 #define BOOST_ASIO_PRIVATE_DETACHED_DEF(n) \
52 template <BOOST_ASIO_VARIADIC_TPARAMS(n)> \
53 void operator()(BOOST_ASIO_VARIADIC_TARGS(n)) \
57 BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_DETACHED_DEF)
58 #undef BOOST_ASIO_PRIVATE_DETACHED_DEF
60 #endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
65 #if !defined(GENERATING_DOCUMENTATION)
67 template <typename Signature>
68 struct async_result<detached_t, Signature>
70 typedef boost::asio::detail::detached_handler completion_handler_type;
72 typedef void return_type;
74 explicit async_result(completion_handler_type&)
82 #if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
84 template <typename Initiation, typename RawCompletionToken, typename... Args>
85 static return_type initiate(
86 BOOST_ASIO_MOVE_ARG(Initiation) initiation,
87 BOOST_ASIO_MOVE_ARG(RawCompletionToken),
88 BOOST_ASIO_MOVE_ARG(Args)... args)
90 BOOST_ASIO_MOVE_CAST(Initiation)(initiation)(
91 detail::detached_handler(detached_t()),
92 BOOST_ASIO_MOVE_CAST(Args)(args)...);
95 #else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
97 template <typename Initiation, typename RawCompletionToken>
98 static return_type initiate(
99 BOOST_ASIO_MOVE_ARG(Initiation) initiation,
100 BOOST_ASIO_MOVE_ARG(RawCompletionToken))
102 BOOST_ASIO_MOVE_CAST(Initiation)(initiation)(
103 detail::detached_handler(detached_t()));
106 #define BOOST_ASIO_PRIVATE_INITIATE_DEF(n) \
107 template <typename Initiation, typename RawCompletionToken, \
108 BOOST_ASIO_VARIADIC_TPARAMS(n)> \
109 static return_type initiate( \
110 BOOST_ASIO_MOVE_ARG(Initiation) initiation, \
111 BOOST_ASIO_MOVE_ARG(RawCompletionToken), \
112 BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \
114 BOOST_ASIO_MOVE_CAST(Initiation)(initiation)( \
115 detail::detached_handler(detached_t()), \
116 BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
119 BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_INITIATE_DEF)
120 #undef BOOST_ASIO_PRIVATE_INITIATE_DEF
122 #endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
125 #endif // !defined(GENERATING_DOCUMENTATION)
130 #include <boost/asio/detail/pop_options.hpp>
132 #endif // BOOST_ASIO_IMPL_DETACHED_HPP