1//
2// handler_type.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_HANDLER_TYPE_HPP
12#define BOOST_ASIO_HANDLER_TYPE_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
20#include <boost/asio/detail/push_options.hpp>
21
22namespace boost {
23namespace asio {
24
25/// Default handler type traits provided for all handlers.
26/**
27 * The handler_type traits class is used for determining the concrete handler
28 * type to be used for an asynchronous operation. It allows the handler type to
29 * be determined at the point where the specific completion handler signature
30 * is known.
31 *
32 * This template may be specialised for user-defined handler types.
33 */
34template <typename Handler, typename Signature>
35struct handler_type
36{
37 /// The handler type for the specific signature.
38 typedef Handler type;
39};
40
41#if !defined(GENERATING_DOCUMENTATION)
42
43template <typename Handler, typename Signature>
44struct handler_type<const Handler, Signature>
45 : handler_type<Handler, Signature> {};
46
47template <typename Handler, typename Signature>
48struct handler_type<volatile Handler, Signature>
49 : handler_type<Handler, Signature> {};
50
51template <typename Handler, typename Signature>
52struct handler_type<const volatile Handler, Signature>
53 : handler_type<Handler, Signature> {};
54
55template <typename Handler, typename Signature>
56struct handler_type<const Handler&, Signature>
57 : handler_type<Handler, Signature> {};
58
59template <typename Handler, typename Signature>
60struct handler_type<volatile Handler&, Signature>
61 : handler_type<Handler, Signature> {};
62
63template <typename Handler, typename Signature>
64struct handler_type<const volatile Handler&, Signature>
65 : handler_type<Handler, Signature> {};
66
67template <typename Handler, typename Signature>
68struct handler_type<Handler&, Signature>
69 : handler_type<Handler, Signature> {};
70
71#if defined(BOOST_ASIO_HAS_MOVE)
72template <typename Handler, typename Signature>
73struct handler_type<Handler&&, Signature>
74 : handler_type<Handler, Signature> {};
75#endif // defined(BOOST_ASIO_HAS_MOVE)
76
77template <typename ReturnType, typename Signature>
78struct handler_type<ReturnType(), Signature>
79 : handler_type<ReturnType(*)(), Signature> {};
80
81template <typename ReturnType, typename Arg1, typename Signature>
82struct handler_type<ReturnType(Arg1), Signature>
83 : handler_type<ReturnType(*)(Arg1), Signature> {};
84
85template <typename ReturnType, typename Arg1, typename Arg2, typename Signature>
86struct handler_type<ReturnType(Arg1, Arg2), Signature>
87 : handler_type<ReturnType(*)(Arg1, Arg2), Signature> {};
88
89template <typename ReturnType, typename Arg1, typename Arg2, typename Arg3,
90 typename Signature>
91struct handler_type<ReturnType(Arg1, Arg2, Arg3), Signature>
92 : handler_type<ReturnType(*)(Arg1, Arg2, Arg3), Signature> {};
93
94template <typename ReturnType, typename Arg1, typename Arg2, typename Arg3,
95 typename Arg4, typename Signature>
96struct handler_type<ReturnType(Arg1, Arg2, Arg3, Arg4), Signature>
97 : handler_type<ReturnType(*)(Arg1, Arg2, Arg3, Arg4), Signature> {};
98
99template <typename ReturnType, typename Arg1, typename Arg2, typename Arg3,
100 typename Arg4, typename Arg5, typename Signature>
101struct handler_type<ReturnType(Arg1, Arg2, Arg3, Arg4, Arg5), Signature>
102 : handler_type<ReturnType(*)(Arg1, Arg2, Arg3, Arg4, Arg5), Signature> {};
103
104#endif // !defined(GENERATING_DOCUMENTATION)
105
106} // namespace asio
107} // namespace boost
108
109#include <boost/asio/detail/pop_options.hpp>
110
111#define BOOST_ASIO_HANDLER_TYPE(h, sig) \
112 typename handler_type<h, sig>::type
113
114#endif // BOOST_ASIO_HANDLER_TYPE_HPP
115