]>
Commit | Line | Data |
---|---|---|
92f5a8d4 TL |
1 | // |
2 | // impl/detached.hpp | |
3 | // ~~~~~~~~~~~~~~~~~ | |
4 | // | |
1e59de90 | 5 | // Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) |
92f5a8d4 TL |
6 | // |
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) | |
9 | // | |
10 | ||
11 | #ifndef BOOST_ASIO_IMPL_DETACHED_HPP | |
12 | #define BOOST_ASIO_IMPL_DETACHED_HPP | |
13 | ||
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) | |
15 | # pragma once | |
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) | |
17 | ||
18 | #include <boost/asio/detail/config.hpp> | |
19 | #include <boost/asio/async_result.hpp> | |
20 | #include <boost/asio/detail/variadic_templates.hpp> | |
21 | ||
22 | #include <boost/asio/detail/push_options.hpp> | |
23 | ||
24 | namespace boost { | |
25 | namespace asio { | |
26 | namespace detail { | |
27 | ||
28 | // Class to adapt a detached_t as a completion handler. | |
29 | class detached_handler | |
30 | { | |
31 | public: | |
32 | typedef void result_type; | |
33 | ||
34 | detached_handler(detached_t) | |
35 | { | |
36 | } | |
37 | ||
38 | #if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) | |
39 | ||
40 | template <typename... Args> | |
41 | void operator()(Args...) | |
42 | { | |
43 | } | |
44 | ||
45 | #else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) | |
46 | ||
47 | void operator()() | |
48 | { | |
49 | } | |
50 | ||
51 | #define BOOST_ASIO_PRIVATE_DETACHED_DEF(n) \ | |
52 | template <BOOST_ASIO_VARIADIC_TPARAMS(n)> \ | |
53 | void operator()(BOOST_ASIO_VARIADIC_TARGS(n)) \ | |
54 | { \ | |
55 | } \ | |
56 | /**/ | |
57 | BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_DETACHED_DEF) | |
58 | #undef BOOST_ASIO_PRIVATE_DETACHED_DEF | |
59 | ||
60 | #endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) | |
61 | }; | |
62 | ||
63 | } // namespace detail | |
64 | ||
65 | #if !defined(GENERATING_DOCUMENTATION) | |
66 | ||
67 | template <typename Signature> | |
68 | struct async_result<detached_t, Signature> | |
69 | { | |
70 | typedef boost::asio::detail::detached_handler completion_handler_type; | |
71 | ||
72 | typedef void return_type; | |
73 | ||
74 | explicit async_result(completion_handler_type&) | |
75 | { | |
76 | } | |
77 | ||
78 | void get() | |
79 | { | |
80 | } | |
81 | ||
82 | #if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) | |
83 | ||
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) | |
89 | { | |
90 | BOOST_ASIO_MOVE_CAST(Initiation)(initiation)( | |
91 | detail::detached_handler(detached_t()), | |
92 | BOOST_ASIO_MOVE_CAST(Args)(args)...); | |
93 | } | |
94 | ||
95 | #else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) | |
96 | ||
97 | template <typename Initiation, typename RawCompletionToken> | |
98 | static return_type initiate( | |
99 | BOOST_ASIO_MOVE_ARG(Initiation) initiation, | |
100 | BOOST_ASIO_MOVE_ARG(RawCompletionToken)) | |
101 | { | |
102 | BOOST_ASIO_MOVE_CAST(Initiation)(initiation)( | |
103 | detail::detached_handler(detached_t())); | |
104 | } | |
105 | ||
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)) \ | |
113 | { \ | |
114 | BOOST_ASIO_MOVE_CAST(Initiation)(initiation)( \ | |
115 | detail::detached_handler(detached_t()), \ | |
116 | BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \ | |
117 | } \ | |
118 | /**/ | |
119 | BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_INITIATE_DEF) | |
120 | #undef BOOST_ASIO_PRIVATE_INITIATE_DEF | |
121 | ||
122 | #endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) | |
123 | }; | |
124 | ||
125 | #endif // !defined(GENERATING_DOCUMENTATION) | |
126 | ||
127 | } // namespace asio | |
128 | } // namespace boost | |
129 | ||
130 | #include <boost/asio/detail/pop_options.hpp> | |
131 | ||
132 | #endif // BOOST_ASIO_IMPL_DETACHED_HPP |