handler_invoke_helpers.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // handler_invoke_helpers.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2010 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. #ifndef ASIO_DETAIL_HANDLER_INVOKE_HELPERS_HPP
  11. #define ASIO_DETAIL_HANDLER_INVOKE_HELPERS_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include "asio/detail/push_options.hpp"
  16. #include "asio/detail/push_options.hpp"
  17. #include <boost/detail/workaround.hpp>
  18. #include <boost/utility/addressof.hpp>
  19. #include "asio/detail/pop_options.hpp"
  20. #include "asio/handler_invoke_hook.hpp"
  21. // Calls to asio_handler_invoke must be made from a namespace that does not
  22. // contain overloads of this function. The asio_handler_invoke_helpers
  23. // namespace is defined here for that purpose.
  24. namespace asio_handler_invoke_helpers {
  25. template <typename Function, typename Context>
  26. inline void invoke(const Function& function, Context& context)
  27. {
  28. #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) \
  29. || BOOST_WORKAROUND(__GNUC__, < 3)
  30. Function tmp(function);
  31. tmp();
  32. #else
  33. using namespace asio;
  34. asio_handler_invoke(function, boost::addressof(context));
  35. #endif
  36. }
  37. } // namespace asio_handler_invoke_helpers
  38. #include "asio/detail/pop_options.hpp"
  39. #endif // ASIO_DETAIL_HANDLER_INVOKE_HELPERS_HPP