2 // handler_base_from_member.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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_HANDLER_BASE_FROM_MEMBER_HPP
12 #define BOOST_ASIO_DETAIL_HANDLER_BASE_FROM_MEMBER_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 // Base class for classes that need a handler data member. Forwards the custom
28 // allocation and invocation hooks to the contained handler.
29 template <typename Handler
>
30 class handler_base_from_member
33 handler_base_from_member(Handler handler
)
42 // Protected destructor to prevent deletion through this type.
43 ~handler_base_from_member()
48 template <typename Handler
>
49 inline void* asio_handler_allocate(std::size_t size
,
50 handler_base_from_member
<Handler
>* this_handler
)
52 return boost_asio_handler_alloc_helpers::allocate(
53 size
, &this_handler
->handler_
);
56 template <typename Handler
>
57 inline void asio_handler_deallocate(void* pointer
, std::size_t size
,
58 handler_base_from_member
<Handler
>* this_handler
)
60 boost_asio_handler_alloc_helpers::deallocate(
61 pointer
, size
, &this_handler
->handler_
);
64 template <typename Function
, typename Handler
>
65 inline void asio_handler_invoke(const Function
& function
,
66 handler_base_from_member
<Handler
>* this_handler
)
68 boost_asio_handler_invoke_helpers::invoke(
69 function
, &this_handler
->handler_
);
76 #include <boost/asio/detail/pop_options.hpp>
78 #endif // BOOST_ASIO_DETAIL_HANDLER_BASE_FROM_MEMBER_HPP