1//
2// detail/handler_invoke_helpers.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_DETAIL_HANDLER_INVOKE_HELPERS_HPP
12#define BOOST_ASIO_DETAIL_HANDLER_INVOKE_HELPERS_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#include <boost/asio/detail/addressof.hpp>
20#include <boost/asio/handler_invoke_hook.hpp>
21
22#include <boost/asio/detail/push_options.hpp>
23
24// Calls to asio_handler_invoke must be made from a namespace that does not
25// contain overloads of this function. The boost_asio_handler_invoke_helpers
26// namespace is defined here for that purpose.
27namespace boost_asio_handler_invoke_helpers {
28
29template <typename Function, typename Context>
30inline void invoke(Function& function, Context& context)
31{
32#if !defined(BOOST_ASIO_HAS_HANDLER_HOOKS)
33 Function tmp(function);
34 tmp();
35#else
36 using boost::asio::asio_handler_invoke;
37 asio_handler_invoke(function, boost::asio::detail::addressof(context));
38#endif
39}
40
41template <typename Function, typename Context>
42inline void invoke(const Function& function, Context& context)
43{
44#if !defined(BOOST_ASIO_HAS_HANDLER_HOOKS)
45 Function tmp(function);
46 tmp();
47#else
48 using boost::asio::asio_handler_invoke;
49 asio_handler_invoke(function, boost::asio::detail::addressof(context));
50#endif
51}
52
53} // namespace boost_asio_handler_invoke_helpers
54
55#include <boost/asio/detail/pop_options.hpp>
56
57#endif // BOOST_ASIO_DETAIL_HANDLER_INVOKE_HELPERS_HPP
58

source code of boost/boost/asio/detail/handler_invoke_helpers.hpp