fix doc example typo
[boost.git] / boost / asio / detail / handler_base_from_member.hpp
blob4bd95ed239e5666e4f86066b09515ee66e3b8851
1 //
2 // handler_base_from_member.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2008 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 //
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)
15 # pragma once
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>
23 namespace boost {
24 namespace asio {
25 namespace detail {
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
32 public:
33 handler_base_from_member(Handler handler)
34 : handler_(handler)
38 //protected:
39 Handler handler_;
41 protected:
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_);
72 } // namespace detail
73 } // namespace asio
74 } // namespace boost
76 #include <boost/asio/detail/pop_options.hpp>
78 #endif // BOOST_ASIO_DETAIL_HANDLER_BASE_FROM_MEMBER_HPP