placeholders.hpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. //
  2. // placeholders.hpp
  3. // ~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2021 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_PLACEHOLDERS_HPP
  11. #define BOOST_ASIO_PLACEHOLDERS_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. #if defined(BOOST_ASIO_HAS_BOOST_BIND)
  17. # include <boost/bind/arg.hpp>
  18. #endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
  19. #include <boost/asio/detail/push_options.hpp>
  20. namespace boost {
  21. namespace asio {
  22. namespace placeholders {
  23. #if defined(GENERATING_DOCUMENTATION)
  24. /// An argument placeholder, for use with boost::bind(), that corresponds to
  25. /// the error argument of a handler for any of the asynchronous functions.
  26. unspecified error;
  27. /// An argument placeholder, for use with boost::bind(), that corresponds to
  28. /// the bytes_transferred argument of a handler for asynchronous functions such
  29. /// as boost::asio::basic_stream_socket::async_write_some or
  30. /// boost::asio::async_write.
  31. unspecified bytes_transferred;
  32. /// An argument placeholder, for use with boost::bind(), that corresponds to
  33. /// the iterator argument of a handler for asynchronous functions such as
  34. /// boost::asio::async_connect.
  35. unspecified iterator;
  36. /// An argument placeholder, for use with boost::bind(), that corresponds to
  37. /// the results argument of a handler for asynchronous functions such as
  38. /// boost::asio::basic_resolver::async_resolve.
  39. unspecified results;
  40. /// An argument placeholder, for use with boost::bind(), that corresponds to
  41. /// the results argument of a handler for asynchronous functions such as
  42. /// boost::asio::async_connect.
  43. unspecified endpoint;
  44. /// An argument placeholder, for use with boost::bind(), that corresponds to
  45. /// the signal_number argument of a handler for asynchronous functions such as
  46. /// boost::asio::signal_set::async_wait.
  47. unspecified signal_number;
  48. #elif defined(BOOST_ASIO_HAS_BOOST_BIND)
  49. # if defined(__BORLANDC__) || defined(__GNUC__)
  50. inline boost::arg<1> error()
  51. {
  52. return boost::arg<1>();
  53. }
  54. inline boost::arg<2> bytes_transferred()
  55. {
  56. return boost::arg<2>();
  57. }
  58. inline boost::arg<2> iterator()
  59. {
  60. return boost::arg<2>();
  61. }
  62. inline boost::arg<2> results()
  63. {
  64. return boost::arg<2>();
  65. }
  66. inline boost::arg<2> endpoint()
  67. {
  68. return boost::arg<2>();
  69. }
  70. inline boost::arg<2> signal_number()
  71. {
  72. return boost::arg<2>();
  73. }
  74. # else
  75. namespace detail
  76. {
  77. template <int Number>
  78. struct placeholder
  79. {
  80. static boost::arg<Number>& get()
  81. {
  82. static boost::arg<Number> result;
  83. return result;
  84. }
  85. };
  86. }
  87. # if defined(BOOST_ASIO_MSVC) && (BOOST_ASIO_MSVC < 1400)
  88. static boost::arg<1>& error
  89. = boost::asio::placeholders::detail::placeholder<1>::get();
  90. static boost::arg<2>& bytes_transferred
  91. = boost::asio::placeholders::detail::placeholder<2>::get();
  92. static boost::arg<2>& iterator
  93. = boost::asio::placeholders::detail::placeholder<2>::get();
  94. static boost::arg<2>& results
  95. = boost::asio::placeholders::detail::placeholder<2>::get();
  96. static boost::arg<2>& endpoint
  97. = boost::asio::placeholders::detail::placeholder<2>::get();
  98. static boost::arg<2>& signal_number
  99. = boost::asio::placeholders::detail::placeholder<2>::get();
  100. # else
  101. namespace
  102. {
  103. boost::arg<1>& error
  104. = boost::asio::placeholders::detail::placeholder<1>::get();
  105. boost::arg<2>& bytes_transferred
  106. = boost::asio::placeholders::detail::placeholder<2>::get();
  107. boost::arg<2>& iterator
  108. = boost::asio::placeholders::detail::placeholder<2>::get();
  109. boost::arg<2>& results
  110. = boost::asio::placeholders::detail::placeholder<2>::get();
  111. boost::arg<2>& endpoint
  112. = boost::asio::placeholders::detail::placeholder<2>::get();
  113. boost::arg<2>& signal_number
  114. = boost::asio::placeholders::detail::placeholder<2>::get();
  115. } // namespace
  116. # endif
  117. # endif
  118. #endif
  119. } // namespace placeholders
  120. } // namespace asio
  121. } // namespace boost
  122. #include <boost/asio/detail/pop_options.hpp>
  123. #endif // BOOST_ASIO_PLACEHOLDERS_HPP