5 // Copyright (c) 2003-2017 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_ASYNC_RESULT_HPP
12 #define BOOST_ASIO_ASYNC_RESULT_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/handler_type.hpp>
21 #include <boost/asio/detail/push_options.hpp>
26 /// An interface for customising the behaviour of an initiating function.
28 * This template may be specialised for user-defined handler types.
30 template <typename Handler>
34 /// The return type of the initiating function.
37 /// Construct an async result from a given handler.
39 * When using a specalised async_result, the constructor has an opportunity
40 * to initialise some state associated with the handler, which is then
41 * returned from the initiating function.
43 explicit async_result(Handler&)
47 /// Obtain the value to be returned from the initiating function.
55 // Helper template to deduce the true type of a handler, capture a local copy
56 // of the handler, and then create an async_result for the handler.
57 template <typename Handler, typename Signature>
58 struct async_result_init
60 explicit async_result_init(BOOST_ASIO_MOVE_ARG(Handler) orig_handler)
61 : handler(BOOST_ASIO_MOVE_CAST(Handler)(orig_handler)),
66 typename handler_type<Handler, Signature>::type handler;
67 async_result<typename handler_type<Handler, Signature>::type> result;
70 template <typename Handler, typename Signature>
71 struct async_result_type_helper
73 typedef typename async_result<
74 typename handler_type<Handler, Signature>::type
82 #include <boost/asio/detail/pop_options.hpp>
84 #if defined(GENERATING_DOCUMENTATION)
85 # define BOOST_ASIO_INITFN_RESULT_TYPE(h, sig) \
87 #elif defined(_MSC_VER) && (_MSC_VER < 1500)
88 # define BOOST_ASIO_INITFN_RESULT_TYPE(h, sig) \
89 typename ::boost::asio::detail::async_result_type_helper<h, sig>::type
91 # define BOOST_ASIO_INITFN_RESULT_TYPE(h, sig) \
92 typename ::boost::asio::async_result< \
93 typename ::boost::asio::handler_type<h, sig>::type>::type
96 #endif // BOOST_ASIO_ASYNC_RESULT_HPP