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 ARCHETYPES_ASYNC_RESULT_HPP
12#define ARCHETYPES_ASYNC_RESULT_HPP
13
14#include <boost/asio/async_result.hpp>
15#include <boost/asio/handler_type.hpp>
16
17namespace archetypes {
18
19struct lazy_handler
20{
21};
22
23struct concrete_handler
24{
25 concrete_handler(lazy_handler)
26 {
27 }
28
29 template <typename Arg1>
30 void operator()(Arg1)
31 {
32 }
33
34 template <typename Arg1, typename Arg2>
35 void operator()(Arg1, Arg2)
36 {
37 }
38};
39
40} // namespace archetypes
41
42namespace boost {
43namespace asio {
44
45template <typename Signature>
46struct handler_type<archetypes::lazy_handler, Signature>
47{
48 typedef archetypes::concrete_handler type;
49};
50
51template <>
52class async_result<archetypes::concrete_handler>
53{
54public:
55 // The return type of the initiating function.
56 typedef int type;
57
58 // Construct an async_result from a given handler.
59 explicit async_result(archetypes::concrete_handler&)
60 {
61 }
62
63 // Obtain the value to be returned from the initiating function.
64 type get()
65 {
66 return 42;
67 }
68};
69
70} // namespace asio
71} // namespace boost
72
73#endif // ARCHETYPES_ASYNC_RESULT_HPP
74

source code of boost/libs/asio/test/archetypes/async_result.hpp