/Src/Dependencies/Boost/boost/asio/detail/handler_invoke_helpers.hpp

http://hadesmem.googlecode.com/ · C++ Header · 60 lines · 38 code · 10 blank · 12 comment · 3 complexity · 68b4ca7a0bf9b8b6b9d9bdb2b86e0d9a MD5 · raw file

  1. //
  2. // detail/handler_invoke_helpers.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2011 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 BOOST_ASIO_DETAIL_HANDLER_INVOKE_HELPERS_HPP
  11. #define BOOST_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 <boost/asio/detail/config.hpp>
  16. #include <boost/detail/workaround.hpp>
  17. #include <boost/utility/addressof.hpp>
  18. #include <boost/asio/handler_invoke_hook.hpp>
  19. #include <boost/asio/detail/push_options.hpp>
  20. // Calls to asio_handler_invoke must be made from a namespace that does not
  21. // contain overloads of this function. The boost_asio_handler_invoke_helpers
  22. // namespace is defined here for that purpose.
  23. namespace boost_asio_handler_invoke_helpers {
  24. template <typename Function, typename Context>
  25. inline void invoke(Function& function, Context& context)
  26. {
  27. #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) \
  28. || BOOST_WORKAROUND(__GNUC__, < 3)
  29. Function tmp(function);
  30. tmp();
  31. #else
  32. using boost::asio::asio_handler_invoke;
  33. asio_handler_invoke(function, boost::addressof(context));
  34. #endif
  35. }
  36. template <typename Function, typename Context>
  37. inline void invoke(const Function& function, Context& context)
  38. {
  39. #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) \
  40. || BOOST_WORKAROUND(__GNUC__, < 3)
  41. Function tmp(function);
  42. tmp();
  43. #else
  44. using boost::asio::asio_handler_invoke;
  45. asio_handler_invoke(function, boost::addressof(context));
  46. #endif
  47. }
  48. } // namespace boost_asio_handler_invoke_helpers
  49. #include <boost/asio/detail/pop_options.hpp>
  50. #endif // BOOST_ASIO_DETAIL_HANDLER_INVOKE_HELPERS_HPP