deferred.hpp
3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//
// impl/deferred.hpp
// ~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2022 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 BOOST_ASIO_IMPL_DEFERRED_HPP
#define BOOST_ASIO_IMPL_DEFERRED_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
#if !defined(GENERATING_DOCUMENTATION)
template <typename Signature>
class async_result<deferred_t, Signature>
{
public:
template <typename Initiation, typename... InitArgs>
static deferred_async_operation<Signature, Initiation, InitArgs...>
initiate(BOOST_ASIO_MOVE_ARG(Initiation) initiation,
deferred_t, BOOST_ASIO_MOVE_ARG(InitArgs)... args)
{
return deferred_async_operation<
Signature, Initiation, InitArgs...>(
deferred_init_tag{},
BOOST_ASIO_MOVE_CAST(Initiation)(initiation),
BOOST_ASIO_MOVE_CAST(InitArgs)(args)...);
}
};
template <typename Function, typename R, typename... Args>
class async_result<deferred_function<Function>, R(Args...)>
{
public:
template <typename Initiation, typename... InitArgs>
static auto initiate(BOOST_ASIO_MOVE_ARG(Initiation) initiation,
deferred_function<Function> token,
BOOST_ASIO_MOVE_ARG(InitArgs)... init_args)
-> decltype(
deferred_sequence<
deferred_async_operation<
R(Args...), Initiation, InitArgs...>,
Function>(deferred_init_tag{},
deferred_async_operation<
R(Args...), Initiation, InitArgs...>(
deferred_init_tag{},
BOOST_ASIO_MOVE_CAST(Initiation)(initiation),
BOOST_ASIO_MOVE_CAST(InitArgs)(init_args)...),
BOOST_ASIO_MOVE_CAST(Function)(token.function_)))
{
return deferred_sequence<
deferred_async_operation<
R(Args...), Initiation, InitArgs...>,
Function>(deferred_init_tag{},
deferred_async_operation<
R(Args...), Initiation, InitArgs...>(
deferred_init_tag{},
BOOST_ASIO_MOVE_CAST(Initiation)(initiation),
BOOST_ASIO_MOVE_CAST(InitArgs)(init_args)...),
BOOST_ASIO_MOVE_CAST(Function)(token.function_));
}
};
template <template <typename, typename> class Associator,
typename Handler, typename Tail, typename DefaultCandidate>
struct associator<Associator,
detail::deferred_sequence_handler<Handler, Tail>,
DefaultCandidate>
: Associator<Handler, DefaultCandidate>
{
static typename Associator<Handler, DefaultCandidate>::type
get(const detail::deferred_sequence_handler<Handler, Tail>& h)
BOOST_ASIO_NOEXCEPT
{
return Associator<Handler, DefaultCandidate>::get(h.handler_);
}
static BOOST_ASIO_AUTO_RETURN_TYPE_PREFIX2(
typename Associator<Handler, DefaultCandidate>::type)
get(const detail::deferred_sequence_handler<Handler, Tail>& h,
const DefaultCandidate& c) BOOST_ASIO_NOEXCEPT
BOOST_ASIO_AUTO_RETURN_TYPE_SUFFIX((
Associator<Handler, DefaultCandidate>::get(h.handler_, c)))
{
return Associator<Handler, DefaultCandidate>::get(h.handler_, c);
}
};
#endif // !defined(GENERATING_DOCUMENTATION)
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_IMPL_DEFERRED_HPP