5 // Copyright (c) 2003-2008 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_DETAIL_BIND_HANDLER_HPP
12 #define BOOST_ASIO_DETAIL_BIND_HANDLER_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/push_options.hpp>
20 #include <boost/asio/detail/handler_alloc_helpers.hpp>
21 #include <boost/asio/detail/handler_invoke_helpers.hpp>
27 template <typename Handler
, typename Arg1
>
31 binder1(const Handler
& handler
, const Arg1
& arg1
)
42 void operator()() const
52 template <typename Handler
, typename Arg1
>
53 inline void* asio_handler_allocate(std::size_t size
,
54 binder1
<Handler
, Arg1
>* this_handler
)
56 return boost_asio_handler_alloc_helpers::allocate(
57 size
, &this_handler
->handler_
);
60 template <typename Handler
, typename Arg1
>
61 inline void asio_handler_deallocate(void* pointer
, std::size_t size
,
62 binder1
<Handler
, Arg1
>* this_handler
)
64 boost_asio_handler_alloc_helpers::deallocate(
65 pointer
, size
, &this_handler
->handler_
);
68 template <typename Function
, typename Handler
, typename Arg1
>
69 inline void asio_handler_invoke(const Function
& function
,
70 binder1
<Handler
, Arg1
>* this_handler
)
72 boost_asio_handler_invoke_helpers::invoke(
73 function
, &this_handler
->handler_
);
76 template <typename Handler
, typename Arg1
>
77 inline binder1
<Handler
, Arg1
> bind_handler(const Handler
& handler
,
80 return binder1
<Handler
, Arg1
>(handler
, arg1
);
83 template <typename Handler
, typename Arg1
, typename Arg2
>
87 binder2(const Handler
& handler
, const Arg1
& arg1
, const Arg2
& arg2
)
96 handler_(arg1_
, arg2_
);
99 void operator()() const
101 handler_(arg1_
, arg2_
);
110 template <typename Handler
, typename Arg1
, typename Arg2
>
111 inline void* asio_handler_allocate(std::size_t size
,
112 binder2
<Handler
, Arg1
, Arg2
>* this_handler
)
114 return boost_asio_handler_alloc_helpers::allocate(
115 size
, &this_handler
->handler_
);
118 template <typename Handler
, typename Arg1
, typename Arg2
>
119 inline void asio_handler_deallocate(void* pointer
, std::size_t size
,
120 binder2
<Handler
, Arg1
, Arg2
>* this_handler
)
122 boost_asio_handler_alloc_helpers::deallocate(
123 pointer
, size
, &this_handler
->handler_
);
126 template <typename Function
, typename Handler
, typename Arg1
, typename Arg2
>
127 inline void asio_handler_invoke(const Function
& function
,
128 binder2
<Handler
, Arg1
, Arg2
>* this_handler
)
130 boost_asio_handler_invoke_helpers::invoke(
131 function
, &this_handler
->handler_
);
134 template <typename Handler
, typename Arg1
, typename Arg2
>
135 inline binder2
<Handler
, Arg1
, Arg2
> bind_handler(const Handler
& handler
,
136 const Arg1
& arg1
, const Arg2
& arg2
)
138 return binder2
<Handler
, Arg1
, Arg2
>(handler
, arg1
, arg2
);
141 template <typename Handler
, typename Arg1
, typename Arg2
, typename Arg3
>
145 binder3(const Handler
& handler
, const Arg1
& arg1
, const Arg2
& arg2
,
156 handler_(arg1_
, arg2_
, arg3_
);
159 void operator()() const
161 handler_(arg1_
, arg2_
, arg3_
);
171 template <typename Handler
, typename Arg1
, typename Arg2
, typename Arg3
>
172 inline void* asio_handler_allocate(std::size_t size
,
173 binder3
<Handler
, Arg1
, Arg2
, Arg3
>* this_handler
)
175 return boost_asio_handler_alloc_helpers::allocate(
176 size
, &this_handler
->handler_
);
179 template <typename Handler
, typename Arg1
, typename Arg2
, typename Arg3
>
180 inline void asio_handler_deallocate(void* pointer
, std::size_t size
,
181 binder3
<Handler
, Arg1
, Arg2
, Arg3
>* this_handler
)
183 boost_asio_handler_alloc_helpers::deallocate(
184 pointer
, size
, &this_handler
->handler_
);
187 template <typename Function
, typename Handler
, typename Arg1
, typename Arg2
,
189 inline void asio_handler_invoke(const Function
& function
,
190 binder3
<Handler
, Arg1
, Arg2
, Arg3
>* this_handler
)
192 boost_asio_handler_invoke_helpers::invoke(
193 function
, &this_handler
->handler_
);
196 template <typename Handler
, typename Arg1
, typename Arg2
, typename Arg3
>
197 inline binder3
<Handler
, Arg1
, Arg2
, Arg3
> bind_handler(const Handler
& handler
,
198 const Arg1
& arg1
, const Arg2
& arg2
, const Arg3
& arg3
)
200 return binder3
<Handler
, Arg1
, Arg2
, Arg3
>(handler
, arg1
, arg2
, arg3
);
203 template <typename Handler
, typename Arg1
, typename Arg2
, typename Arg3
,
208 binder4(const Handler
& handler
, const Arg1
& arg1
, const Arg2
& arg2
,
209 const Arg3
& arg3
, const Arg4
& arg4
)
220 handler_(arg1_
, arg2_
, arg3_
, arg4_
);
223 void operator()() const
225 handler_(arg1_
, arg2_
, arg3_
, arg4_
);
236 template <typename Handler
, typename Arg1
, typename Arg2
, typename Arg3
,
238 inline void* asio_handler_allocate(std::size_t size
,
239 binder4
<Handler
, Arg1
, Arg2
, Arg3
, Arg4
>* this_handler
)
241 return boost_asio_handler_alloc_helpers::allocate(
242 size
, &this_handler
->handler_
);
245 template <typename Handler
, typename Arg1
, typename Arg2
, typename Arg3
,
247 inline void asio_handler_deallocate(void* pointer
, std::size_t size
,
248 binder4
<Handler
, Arg1
, Arg2
, Arg3
, Arg4
>* this_handler
)
250 boost_asio_handler_alloc_helpers::deallocate(
251 pointer
, size
, &this_handler
->handler_
);
254 template <typename Function
, typename Handler
, typename Arg1
, typename Arg2
,
255 typename Arg3
, typename Arg4
>
256 inline void asio_handler_invoke(const Function
& function
,
257 binder4
<Handler
, Arg1
, Arg2
, Arg3
, Arg4
>* this_handler
)
259 boost_asio_handler_invoke_helpers::invoke(
260 function
, &this_handler
->handler_
);
263 template <typename Handler
, typename Arg1
, typename Arg2
, typename Arg3
,
265 inline binder4
<Handler
, Arg1
, Arg2
, Arg3
, Arg4
> bind_handler(
266 const Handler
& handler
, const Arg1
& arg1
, const Arg2
& arg2
,
267 const Arg3
& arg3
, const Arg4
& arg4
)
269 return binder4
<Handler
, Arg1
, Arg2
, Arg3
, Arg4
>(handler
, arg1
, arg2
, arg3
,
273 template <typename Handler
, typename Arg1
, typename Arg2
, typename Arg3
,
274 typename Arg4
, typename Arg5
>
278 binder5(const Handler
& handler
, const Arg1
& arg1
, const Arg2
& arg2
,
279 const Arg3
& arg3
, const Arg4
& arg4
, const Arg5
& arg5
)
291 handler_(arg1_
, arg2_
, arg3_
, arg4_
, arg5_
);
294 void operator()() const
296 handler_(arg1_
, arg2_
, arg3_
, arg4_
, arg5_
);
308 template <typename Handler
, typename Arg1
, typename Arg2
, typename Arg3
,
309 typename Arg4
, typename Arg5
>
310 inline void* asio_handler_allocate(std::size_t size
,
311 binder5
<Handler
, Arg1
, Arg2
, Arg3
, Arg4
, Arg5
>* this_handler
)
313 return boost_asio_handler_alloc_helpers::allocate(
314 size
, &this_handler
->handler_
);
317 template <typename Handler
, typename Arg1
, typename Arg2
, typename Arg3
,
318 typename Arg4
, typename Arg5
>
319 inline void asio_handler_deallocate(void* pointer
, std::size_t size
,
320 binder5
<Handler
, Arg1
, Arg2
, Arg3
, Arg4
, Arg5
>* this_handler
)
322 boost_asio_handler_alloc_helpers::deallocate(
323 pointer
, size
, &this_handler
->handler_
);
326 template <typename Function
, typename Handler
, typename Arg1
, typename Arg2
,
327 typename Arg3
, typename Arg4
, typename Arg5
>
328 inline void asio_handler_invoke(const Function
& function
,
329 binder5
<Handler
, Arg1
, Arg2
, Arg3
, Arg4
, Arg5
>* this_handler
)
331 boost_asio_handler_invoke_helpers::invoke(
332 function
, &this_handler
->handler_
);
335 template <typename Handler
, typename Arg1
, typename Arg2
, typename Arg3
,
336 typename Arg4
, typename Arg5
>
337 inline binder5
<Handler
, Arg1
, Arg2
, Arg3
, Arg4
, Arg5
> bind_handler(
338 const Handler
& handler
, const Arg1
& arg1
, const Arg2
& arg2
,
339 const Arg3
& arg3
, const Arg4
& arg4
, const Arg5
& arg5
)
341 return binder5
<Handler
, Arg1
, Arg2
, Arg3
, Arg4
, Arg5
>(handler
, arg1
, arg2
,
345 } // namespace detail
349 #include <boost/asio/detail/pop_options.hpp>
351 #endif // BOOST_ASIO_DETAIL_BIND_HANDLER_HPP