comparison DEPENDENCIES/generic/include/boost/asio/async_result.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children c530137014c0
comparison
equal deleted inserted replaced
15:663ca0da4350 16:2665513ce2d3
1 //
2 // async_result.hpp
3 // ~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2013 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
23 namespace boost {
24 namespace 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 */
30 template <typename Handler>
31 class async_result
32 {
33 public:
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
53 namespace 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.
57 template <typename Handler, typename Signature>
58 struct 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
70 template <typename Handler, typename Signature>
71 struct 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