]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/asio/bind_cancellation_slot.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / asio / bind_cancellation_slot.hpp
1 //
2 // bind_cancellation_slot.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
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_BIND_CANCELLATION_SLOT_HPP
12 #define BOOST_ASIO_BIND_CANCELLATION_SLOT_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/detail/type_traits.hpp>
20 #include <boost/asio/detail/variadic_templates.hpp>
21 #include <boost/asio/associated_cancellation_slot.hpp>
22 #include <boost/asio/associator.hpp>
23 #include <boost/asio/async_result.hpp>
24
25 #include <boost/asio/detail/push_options.hpp>
26
27 namespace boost {
28 namespace asio {
29 namespace detail {
30
31 // Helper to automatically define nested typedef result_type.
32
33 template <typename T, typename = void>
34 struct cancellation_slot_binder_result_type
35 {
36 protected:
37 typedef void result_type_or_void;
38 };
39
40 template <typename T>
41 struct cancellation_slot_binder_result_type<T,
42 typename void_type<typename T::result_type>::type>
43 {
44 typedef typename T::result_type result_type;
45 protected:
46 typedef result_type result_type_or_void;
47 };
48
49 template <typename R>
50 struct cancellation_slot_binder_result_type<R(*)()>
51 {
52 typedef R result_type;
53 protected:
54 typedef result_type result_type_or_void;
55 };
56
57 template <typename R>
58 struct cancellation_slot_binder_result_type<R(&)()>
59 {
60 typedef R result_type;
61 protected:
62 typedef result_type result_type_or_void;
63 };
64
65 template <typename R, typename A1>
66 struct cancellation_slot_binder_result_type<R(*)(A1)>
67 {
68 typedef R result_type;
69 protected:
70 typedef result_type result_type_or_void;
71 };
72
73 template <typename R, typename A1>
74 struct cancellation_slot_binder_result_type<R(&)(A1)>
75 {
76 typedef R result_type;
77 protected:
78 typedef result_type result_type_or_void;
79 };
80
81 template <typename R, typename A1, typename A2>
82 struct cancellation_slot_binder_result_type<R(*)(A1, A2)>
83 {
84 typedef R result_type;
85 protected:
86 typedef result_type result_type_or_void;
87 };
88
89 template <typename R, typename A1, typename A2>
90 struct cancellation_slot_binder_result_type<R(&)(A1, A2)>
91 {
92 typedef R result_type;
93 protected:
94 typedef result_type result_type_or_void;
95 };
96
97 // Helper to automatically define nested typedef argument_type.
98
99 template <typename T, typename = void>
100 struct cancellation_slot_binder_argument_type {};
101
102 template <typename T>
103 struct cancellation_slot_binder_argument_type<T,
104 typename void_type<typename T::argument_type>::type>
105 {
106 typedef typename T::argument_type argument_type;
107 };
108
109 template <typename R, typename A1>
110 struct cancellation_slot_binder_argument_type<R(*)(A1)>
111 {
112 typedef A1 argument_type;
113 };
114
115 template <typename R, typename A1>
116 struct cancellation_slot_binder_argument_type<R(&)(A1)>
117 {
118 typedef A1 argument_type;
119 };
120
121 // Helper to automatically define nested typedefs first_argument_type and
122 // second_argument_type.
123
124 template <typename T, typename = void>
125 struct cancellation_slot_binder_argument_types {};
126
127 template <typename T>
128 struct cancellation_slot_binder_argument_types<T,
129 typename void_type<typename T::first_argument_type>::type>
130 {
131 typedef typename T::first_argument_type first_argument_type;
132 typedef typename T::second_argument_type second_argument_type;
133 };
134
135 template <typename R, typename A1, typename A2>
136 struct cancellation_slot_binder_argument_type<R(*)(A1, A2)>
137 {
138 typedef A1 first_argument_type;
139 typedef A2 second_argument_type;
140 };
141
142 template <typename R, typename A1, typename A2>
143 struct cancellation_slot_binder_argument_type<R(&)(A1, A2)>
144 {
145 typedef A1 first_argument_type;
146 typedef A2 second_argument_type;
147 };
148
149 // Helper to enable SFINAE on zero-argument operator() below.
150
151 template <typename T, typename = void>
152 struct cancellation_slot_binder_result_of0
153 {
154 typedef void type;
155 };
156
157 template <typename T>
158 struct cancellation_slot_binder_result_of0<T,
159 typename void_type<typename result_of<T()>::type>::type>
160 {
161 typedef typename result_of<T()>::type type;
162 };
163
164 } // namespace detail
165
166 /// A call wrapper type to bind a cancellation slot of type @c CancellationSlot
167 /// to an object of type @c T.
168 template <typename T, typename CancellationSlot>
169 class cancellation_slot_binder
170 #if !defined(GENERATING_DOCUMENTATION)
171 : public detail::cancellation_slot_binder_result_type<T>,
172 public detail::cancellation_slot_binder_argument_type<T>,
173 public detail::cancellation_slot_binder_argument_types<T>
174 #endif // !defined(GENERATING_DOCUMENTATION)
175 {
176 public:
177 /// The type of the target object.
178 typedef T target_type;
179
180 /// The type of the associated cancellation slot.
181 typedef CancellationSlot cancellation_slot_type;
182
183 #if defined(GENERATING_DOCUMENTATION)
184 /// The return type if a function.
185 /**
186 * The type of @c result_type is based on the type @c T of the wrapper's
187 * target object:
188 *
189 * @li if @c T is a pointer to function type, @c result_type is a synonym for
190 * the return type of @c T;
191 *
192 * @li if @c T is a class type with a member type @c result_type, then @c
193 * result_type is a synonym for @c T::result_type;
194 *
195 * @li otherwise @c result_type is not defined.
196 */
197 typedef see_below result_type;
198
199 /// The type of the function's argument.
200 /**
201 * The type of @c argument_type is based on the type @c T of the wrapper's
202 * target object:
203 *
204 * @li if @c T is a pointer to a function type accepting a single argument,
205 * @c argument_type is a synonym for the return type of @c T;
206 *
207 * @li if @c T is a class type with a member type @c argument_type, then @c
208 * argument_type is a synonym for @c T::argument_type;
209 *
210 * @li otherwise @c argument_type is not defined.
211 */
212 typedef see_below argument_type;
213
214 /// The type of the function's first argument.
215 /**
216 * The type of @c first_argument_type is based on the type @c T of the
217 * wrapper's target object:
218 *
219 * @li if @c T is a pointer to a function type accepting two arguments, @c
220 * first_argument_type is a synonym for the return type of @c T;
221 *
222 * @li if @c T is a class type with a member type @c first_argument_type,
223 * then @c first_argument_type is a synonym for @c T::first_argument_type;
224 *
225 * @li otherwise @c first_argument_type is not defined.
226 */
227 typedef see_below first_argument_type;
228
229 /// The type of the function's second argument.
230 /**
231 * The type of @c second_argument_type is based on the type @c T of the
232 * wrapper's target object:
233 *
234 * @li if @c T is a pointer to a function type accepting two arguments, @c
235 * second_argument_type is a synonym for the return type of @c T;
236 *
237 * @li if @c T is a class type with a member type @c first_argument_type,
238 * then @c second_argument_type is a synonym for @c T::second_argument_type;
239 *
240 * @li otherwise @c second_argument_type is not defined.
241 */
242 typedef see_below second_argument_type;
243 #endif // defined(GENERATING_DOCUMENTATION)
244
245 /// Construct a cancellation slot wrapper for the specified object.
246 /**
247 * This constructor is only valid if the type @c T is constructible from type
248 * @c U.
249 */
250 template <typename U>
251 cancellation_slot_binder(const cancellation_slot_type& s,
252 BOOST_ASIO_MOVE_ARG(U) u)
253 : slot_(s),
254 target_(BOOST_ASIO_MOVE_CAST(U)(u))
255 {
256 }
257
258 /// Copy constructor.
259 cancellation_slot_binder(const cancellation_slot_binder& other)
260 : slot_(other.get_cancellation_slot()),
261 target_(other.get())
262 {
263 }
264
265 /// Construct a copy, but specify a different cancellation slot.
266 cancellation_slot_binder(const cancellation_slot_type& s,
267 const cancellation_slot_binder& other)
268 : slot_(s),
269 target_(other.get())
270 {
271 }
272
273 /// Construct a copy of a different cancellation slot wrapper type.
274 /**
275 * This constructor is only valid if the @c CancellationSlot type is
276 * constructible from type @c OtherCancellationSlot, and the type @c T is
277 * constructible from type @c U.
278 */
279 template <typename U, typename OtherCancellationSlot>
280 cancellation_slot_binder(
281 const cancellation_slot_binder<U, OtherCancellationSlot>& other)
282 : slot_(other.get_cancellation_slot()),
283 target_(other.get())
284 {
285 }
286
287 /// Construct a copy of a different cancellation slot wrapper type, but
288 /// specify a different cancellation slot.
289 /**
290 * This constructor is only valid if the type @c T is constructible from type
291 * @c U.
292 */
293 template <typename U, typename OtherCancellationSlot>
294 cancellation_slot_binder(const cancellation_slot_type& s,
295 const cancellation_slot_binder<U, OtherCancellationSlot>& other)
296 : slot_(s),
297 target_(other.get())
298 {
299 }
300
301 #if defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
302
303 /// Move constructor.
304 cancellation_slot_binder(cancellation_slot_binder&& other)
305 : slot_(BOOST_ASIO_MOVE_CAST(cancellation_slot_type)(
306 other.get_cancellation_slot())),
307 target_(BOOST_ASIO_MOVE_CAST(T)(other.get()))
308 {
309 }
310
311 /// Move construct the target object, but specify a different cancellation
312 /// slot.
313 cancellation_slot_binder(const cancellation_slot_type& s,
314 cancellation_slot_binder&& other)
315 : slot_(s),
316 target_(BOOST_ASIO_MOVE_CAST(T)(other.get()))
317 {
318 }
319
320 /// Move construct from a different cancellation slot wrapper type.
321 template <typename U, typename OtherCancellationSlot>
322 cancellation_slot_binder(
323 cancellation_slot_binder<U, OtherCancellationSlot>&& other)
324 : slot_(BOOST_ASIO_MOVE_CAST(OtherCancellationSlot)(
325 other.get_cancellation_slot())),
326 target_(BOOST_ASIO_MOVE_CAST(U)(other.get()))
327 {
328 }
329
330 /// Move construct from a different cancellation slot wrapper type, but
331 /// specify a different cancellation slot.
332 template <typename U, typename OtherCancellationSlot>
333 cancellation_slot_binder(const cancellation_slot_type& s,
334 cancellation_slot_binder<U, OtherCancellationSlot>&& other)
335 : slot_(s),
336 target_(BOOST_ASIO_MOVE_CAST(U)(other.get()))
337 {
338 }
339
340 #endif // defined(BOOST_ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
341
342 /// Destructor.
343 ~cancellation_slot_binder()
344 {
345 }
346
347 /// Obtain a reference to the target object.
348 target_type& get() BOOST_ASIO_NOEXCEPT
349 {
350 return target_;
351 }
352
353 /// Obtain a reference to the target object.
354 const target_type& get() const BOOST_ASIO_NOEXCEPT
355 {
356 return target_;
357 }
358
359 /// Obtain the associated cancellation slot.
360 cancellation_slot_type get_cancellation_slot() const BOOST_ASIO_NOEXCEPT
361 {
362 return slot_;
363 }
364
365 #if defined(GENERATING_DOCUMENTATION)
366
367 template <typename... Args> auto operator()(Args&& ...);
368 template <typename... Args> auto operator()(Args&& ...) const;
369
370 #elif defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
371
372 /// Forwarding function call operator.
373 template <typename... Args>
374 typename result_of<T(Args...)>::type operator()(
375 BOOST_ASIO_MOVE_ARG(Args)... args)
376 {
377 return target_(BOOST_ASIO_MOVE_CAST(Args)(args)...);
378 }
379
380 /// Forwarding function call operator.
381 template <typename... Args>
382 typename result_of<T(Args...)>::type operator()(
383 BOOST_ASIO_MOVE_ARG(Args)... args) const
384 {
385 return target_(BOOST_ASIO_MOVE_CAST(Args)(args)...);
386 }
387
388 #elif defined(BOOST_ASIO_HAS_STD_TYPE_TRAITS) && !defined(_MSC_VER)
389
390 typename detail::cancellation_slot_binder_result_of0<T>::type operator()()
391 {
392 return target_();
393 }
394
395 typename detail::cancellation_slot_binder_result_of0<T>::type
396 operator()() const
397 {
398 return target_();
399 }
400
401 #define BOOST_ASIO_PRIVATE_BINDER_CALL_DEF(n) \
402 template <BOOST_ASIO_VARIADIC_TPARAMS(n)> \
403 typename result_of<T(BOOST_ASIO_VARIADIC_TARGS(n))>::type operator()( \
404 BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \
405 { \
406 return target_(BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
407 } \
408 \
409 template <BOOST_ASIO_VARIADIC_TPARAMS(n)> \
410 typename result_of<T(BOOST_ASIO_VARIADIC_TARGS(n))>::type operator()( \
411 BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) const \
412 { \
413 return target_(BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
414 } \
415 /**/
416 BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_BINDER_CALL_DEF)
417 #undef BOOST_ASIO_PRIVATE_BINDER_CALL_DEF
418
419 #else // defined(BOOST_ASIO_HAS_STD_TYPE_TRAITS) && !defined(_MSC_VER)
420
421 typedef typename detail::cancellation_slot_binder_result_type<
422 T>::result_type_or_void result_type_or_void;
423
424 result_type_or_void operator()()
425 {
426 return target_();
427 }
428
429 result_type_or_void operator()() const
430 {
431 return target_();
432 }
433
434 #define BOOST_ASIO_PRIVATE_BINDER_CALL_DEF(n) \
435 template <BOOST_ASIO_VARIADIC_TPARAMS(n)> \
436 result_type_or_void operator()( \
437 BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \
438 { \
439 return target_(BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
440 } \
441 \
442 template <BOOST_ASIO_VARIADIC_TPARAMS(n)> \
443 result_type_or_void operator()( \
444 BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) const \
445 { \
446 return target_(BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
447 } \
448 /**/
449 BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_BINDER_CALL_DEF)
450 #undef BOOST_ASIO_PRIVATE_BINDER_CALL_DEF
451
452 #endif // defined(BOOST_ASIO_HAS_STD_TYPE_TRAITS) && !defined(_MSC_VER)
453
454 private:
455 CancellationSlot slot_;
456 T target_;
457 };
458
459 /// Associate an object of type @c T with a cancellation slot of type
460 /// @c CancellationSlot.
461 template <typename CancellationSlot, typename T>
462 BOOST_ASIO_NODISCARD inline
463 cancellation_slot_binder<typename decay<T>::type, CancellationSlot>
464 bind_cancellation_slot(const CancellationSlot& s, BOOST_ASIO_MOVE_ARG(T) t)
465 {
466 return cancellation_slot_binder<
467 typename decay<T>::type, CancellationSlot>(
468 s, BOOST_ASIO_MOVE_CAST(T)(t));
469 }
470
471 #if !defined(GENERATING_DOCUMENTATION)
472
473 namespace detail {
474
475 template <typename TargetAsyncResult,
476 typename CancellationSlot, typename = void>
477 struct cancellation_slot_binder_async_result_completion_handler_type
478 {
479 };
480
481 template <typename TargetAsyncResult, typename CancellationSlot>
482 struct cancellation_slot_binder_async_result_completion_handler_type<
483 TargetAsyncResult, CancellationSlot,
484 typename void_type<
485 typename TargetAsyncResult::completion_handler_type
486 >::type>
487 {
488 typedef cancellation_slot_binder<
489 typename TargetAsyncResult::completion_handler_type, CancellationSlot>
490 completion_handler_type;
491 };
492
493 template <typename TargetAsyncResult, typename = void>
494 struct cancellation_slot_binder_async_result_return_type
495 {
496 };
497
498 template <typename TargetAsyncResult>
499 struct cancellation_slot_binder_async_result_return_type<
500 TargetAsyncResult,
501 typename void_type<
502 typename TargetAsyncResult::return_type
503 >::type>
504 {
505 typedef typename TargetAsyncResult::return_type return_type;
506 };
507
508 } // namespace detail
509
510 template <typename T, typename CancellationSlot, typename Signature>
511 class async_result<cancellation_slot_binder<T, CancellationSlot>, Signature> :
512 public detail::cancellation_slot_binder_async_result_completion_handler_type<
513 async_result<T, Signature>, CancellationSlot>,
514 public detail::cancellation_slot_binder_async_result_return_type<
515 async_result<T, Signature> >
516 {
517 public:
518 explicit async_result(cancellation_slot_binder<T, CancellationSlot>& b)
519 : target_(b.get())
520 {
521 }
522
523 typename async_result<T, Signature>::return_type get()
524 {
525 return target_.get();
526 }
527
528 template <typename Initiation>
529 struct init_wrapper
530 {
531 template <typename Init>
532 init_wrapper(const CancellationSlot& slot, BOOST_ASIO_MOVE_ARG(Init) init)
533 : slot_(slot),
534 initiation_(BOOST_ASIO_MOVE_CAST(Init)(init))
535 {
536 }
537
538 #if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
539
540 template <typename Handler, typename... Args>
541 void operator()(
542 BOOST_ASIO_MOVE_ARG(Handler) handler,
543 BOOST_ASIO_MOVE_ARG(Args)... args)
544 {
545 BOOST_ASIO_MOVE_CAST(Initiation)(initiation_)(
546 cancellation_slot_binder<
547 typename decay<Handler>::type, CancellationSlot>(
548 slot_, BOOST_ASIO_MOVE_CAST(Handler)(handler)),
549 BOOST_ASIO_MOVE_CAST(Args)(args)...);
550 }
551
552 template <typename Handler, typename... Args>
553 void operator()(
554 BOOST_ASIO_MOVE_ARG(Handler) handler,
555 BOOST_ASIO_MOVE_ARG(Args)... args) const
556 {
557 initiation_(
558 cancellation_slot_binder<
559 typename decay<Handler>::type, CancellationSlot>(
560 slot_, BOOST_ASIO_MOVE_CAST(Handler)(handler)),
561 BOOST_ASIO_MOVE_CAST(Args)(args)...);
562 }
563
564 #else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
565
566 template <typename Handler>
567 void operator()(
568 BOOST_ASIO_MOVE_ARG(Handler) handler)
569 {
570 BOOST_ASIO_MOVE_CAST(Initiation)(initiation_)(
571 cancellation_slot_binder<
572 typename decay<Handler>::type, CancellationSlot>(
573 slot_, BOOST_ASIO_MOVE_CAST(Handler)(handler)));
574 }
575
576 template <typename Handler>
577 void operator()(
578 BOOST_ASIO_MOVE_ARG(Handler) handler) const
579 {
580 initiation_(
581 cancellation_slot_binder<
582 typename decay<Handler>::type, CancellationSlot>(
583 slot_, BOOST_ASIO_MOVE_CAST(Handler)(handler)));
584 }
585
586 #define BOOST_ASIO_PRIVATE_INIT_WRAPPER_DEF(n) \
587 template <typename Handler, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
588 void operator()( \
589 BOOST_ASIO_MOVE_ARG(Handler) handler, \
590 BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \
591 { \
592 BOOST_ASIO_MOVE_CAST(Initiation)(initiation_)( \
593 cancellation_slot_binder< \
594 typename decay<Handler>::type, CancellationSlot>( \
595 slot_, BOOST_ASIO_MOVE_CAST(Handler)(handler)), \
596 BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
597 } \
598 \
599 template <typename Handler, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
600 void operator()( \
601 BOOST_ASIO_MOVE_ARG(Handler) handler, \
602 BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) const \
603 { \
604 initiation_( \
605 cancellation_slot_binder< \
606 typename decay<Handler>::type, CancellationSlot>( \
607 slot_, BOOST_ASIO_MOVE_CAST(Handler)(handler)), \
608 BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
609 } \
610 /**/
611 BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_INIT_WRAPPER_DEF)
612 #undef BOOST_ASIO_PRIVATE_INIT_WRAPPER_DEF
613
614 #endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
615
616 CancellationSlot slot_;
617 Initiation initiation_;
618 };
619
620 #if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
621
622 template <typename Initiation, typename RawCompletionToken, typename... Args>
623 static BOOST_ASIO_INITFN_DEDUCED_RESULT_TYPE(T, Signature,
624 (async_initiate<T, Signature>(
625 declval<init_wrapper<typename decay<Initiation>::type> >(),
626 declval<RawCompletionToken>().get(),
627 declval<BOOST_ASIO_MOVE_ARG(Args)>()...)))
628 initiate(
629 BOOST_ASIO_MOVE_ARG(Initiation) initiation,
630 BOOST_ASIO_MOVE_ARG(RawCompletionToken) token,
631 BOOST_ASIO_MOVE_ARG(Args)... args)
632 {
633 return async_initiate<T, Signature>(
634 init_wrapper<typename decay<Initiation>::type>(
635 token.get_cancellation_slot(),
636 BOOST_ASIO_MOVE_CAST(Initiation)(initiation)),
637 token.get(), BOOST_ASIO_MOVE_CAST(Args)(args)...);
638 }
639
640 #else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
641
642 template <typename Initiation, typename RawCompletionToken>
643 static BOOST_ASIO_INITFN_DEDUCED_RESULT_TYPE(T, Signature,
644 (async_initiate<T, Signature>(
645 declval<init_wrapper<typename decay<Initiation>::type> >(),
646 declval<RawCompletionToken>().get())))
647 initiate(
648 BOOST_ASIO_MOVE_ARG(Initiation) initiation,
649 BOOST_ASIO_MOVE_ARG(RawCompletionToken) token)
650 {
651 return async_initiate<T, Signature>(
652 init_wrapper<typename decay<Initiation>::type>(
653 token.get_cancellation_slot(),
654 BOOST_ASIO_MOVE_CAST(Initiation)(initiation)),
655 token.get());
656 }
657
658 #define BOOST_ASIO_PRIVATE_INITIATE_DEF(n) \
659 template <typename Initiation, typename RawCompletionToken, \
660 BOOST_ASIO_VARIADIC_TPARAMS(n)> \
661 static BOOST_ASIO_INITFN_DEDUCED_RESULT_TYPE(T, Signature, \
662 (async_initiate<T, Signature>( \
663 declval<init_wrapper<typename decay<Initiation>::type> >(), \
664 declval<RawCompletionToken>().get(), \
665 BOOST_ASIO_VARIADIC_MOVE_DECLVAL(n)))) \
666 initiate( \
667 BOOST_ASIO_MOVE_ARG(Initiation) initiation, \
668 BOOST_ASIO_MOVE_ARG(RawCompletionToken) token, \
669 BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \
670 { \
671 return async_initiate<T, Signature>( \
672 init_wrapper<typename decay<Initiation>::type>( \
673 token.get_cancellation_slot(), \
674 BOOST_ASIO_MOVE_CAST(Initiation)(initiation)), \
675 token.get(), BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
676 } \
677 /**/
678 BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_INITIATE_DEF)
679 #undef BOOST_ASIO_PRIVATE_INITIATE_DEF
680
681 #endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
682
683 private:
684 async_result(const async_result&) BOOST_ASIO_DELETED;
685 async_result& operator=(const async_result&) BOOST_ASIO_DELETED;
686
687 async_result<T, Signature> target_;
688 };
689
690 template <template <typename, typename> class Associator,
691 typename T, typename CancellationSlot, typename DefaultCandidate>
692 struct associator<Associator,
693 cancellation_slot_binder<T, CancellationSlot>,
694 DefaultCandidate>
695 {
696 typedef typename Associator<T, DefaultCandidate>::type type;
697
698 static type get(const cancellation_slot_binder<T, CancellationSlot>& b,
699 const DefaultCandidate& c = DefaultCandidate()) BOOST_ASIO_NOEXCEPT
700 {
701 return Associator<T, DefaultCandidate>::get(b.get(), c);
702 }
703 };
704
705 template <typename T, typename CancellationSlot, typename CancellationSlot1>
706 struct associated_cancellation_slot<
707 cancellation_slot_binder<T, CancellationSlot>,
708 CancellationSlot1>
709 {
710 typedef CancellationSlot type;
711
712 static type get(const cancellation_slot_binder<T, CancellationSlot>& b,
713 const CancellationSlot1& = CancellationSlot1()) BOOST_ASIO_NOEXCEPT
714 {
715 return b.get_cancellation_slot();
716 }
717 };
718
719 #endif // !defined(GENERATING_DOCUMENTATION)
720
721 } // namespace asio
722 } // namespace boost
723
724 #include <boost/asio/detail/pop_options.hpp>
725
726 #endif // BOOST_ASIO_BIND_CANCELLATION_SLOT_HPP