1//
2// async_result.hpp
3// ~~~~~~~~~~~~~~~~
4//
5// Copyright (c) 2003-2015 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_ASYNC_RESULT_HPP
12#define BOOST_ASIO_ASYNC_RESULT_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/handler_type.hpp>
20
21#include <boost/asio/detail/push_options.hpp>
22
23namespace boost {
24namespace asio {
25
26/// An interface for customising the behaviour of an initiating function.
27/**
28 * This template may be specialised for user-defined handler types.
29 */
30template <typename Handler>
31class async_result
32{
33public:
34 /// The return type of the initiating function.
35 typedef void type;
36
37 /// Construct an async result from a given handler.
38 /**
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.
42 */
43 explicit async_result(Handler&)
44 {
45 }
46
47 /// Obtain the value to be returned from the initiating function.
48 type get()
49 {
50 }
51};
52
53namespace detail {
54
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.
57template <typename Handler, typename Signature>
58struct async_result_init
59{
60 explicit async_result_init(BOOST_ASIO_MOVE_ARG(Handler) orig_handler)
61 : handler(BOOST_ASIO_MOVE_CAST(Handler)(orig_handler)),
62 result(handler)
63 {
64 }
65
66 typename handler_type<Handler, Signature>::type handler;
67 async_result<typename handler_type<Handler, Signature>::type> result;
68};
69
70template <typename Handler, typename Signature>
71struct async_result_type_helper
72{
73 typedef typename async_result<
74 typename handler_type<Handler, Signature>::type
75 >::type type;
76};
77
78} // namespace detail
79} // namespace asio
80} // namespace boost
81
82#include <boost/asio/detail/pop_options.hpp>
83
84#if defined(GENERATING_DOCUMENTATION)
85# define BOOST_ASIO_INITFN_RESULT_TYPE(h, sig) \
86 void_or_deduced
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
90#else
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
94#endif
95
96#endif // BOOST_ASIO_ASYNC_RESULT_HPP
97

source code of boost/boost/asio/async_result.hpp