detached.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // experimental/impl/detached.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2018 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_EXPERIMENTAL_IMPL_DETACHED_HPP
  11. #define BOOST_ASIO_EXPERIMENTAL_IMPL_DETACHED_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/asio/async_result.hpp>
  17. #include <boost/asio/detail/variadic_templates.hpp>
  18. #include <boost/asio/handler_type.hpp>
  19. #include <boost/system/system_error.hpp>
  20. #include <boost/asio/detail/push_options.hpp>
  21. namespace boost {
  22. namespace asio {
  23. namespace experimental {
  24. namespace detail {
  25. // Class to adapt a detached_t as a completion handler.
  26. class detached_handler
  27. {
  28. public:
  29. detached_handler(detached_t)
  30. {
  31. }
  32. #if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
  33. template <typename... Args>
  34. void operator()(Args...)
  35. {
  36. }
  37. #else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
  38. void operator()()
  39. {
  40. }
  41. #define BOOST_ASIO_PRIVATE_DETACHED_DEF(n) \
  42. template <BOOST_ASIO_VARIADIC_TPARAMS(n)> \
  43. void operator()(BOOST_ASIO_VARIADIC_BYVAL_PARAMS(n)) \
  44. { \
  45. } \
  46. /**/
  47. BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_DETACHED_DEF)
  48. #undef BOOST_ASIO_PRIVATE_DETACHED_DEF
  49. #endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
  50. };
  51. } // namespace detail
  52. } // namespace experimental
  53. #if !defined(GENERATING_DOCUMENTATION)
  54. template <typename Signature>
  55. struct async_result<experimental::detached_t, Signature>
  56. {
  57. typedef boost::asio::experimental::detail::detached_handler
  58. completion_handler_type;
  59. typedef void return_type;
  60. explicit async_result(completion_handler_type&)
  61. {
  62. }
  63. void get()
  64. {
  65. }
  66. };
  67. #endif // !defined(GENERATING_DOCUMENTATION)
  68. } // namespace asio
  69. } // namespace boost
  70. #include <boost/asio/detail/pop_options.hpp>
  71. #endif // BOOST_ASIO_EXPERIMENTAL_IMPL_DETACHED_HPP