placeholders.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //
  2. // placeholders.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. #ifndef ASIO_PLACEHOLDERS_HPP
  11. #define ASIO_PLACEHOLDERS_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include "asio/detail/config.hpp"
  16. #if defined(ASIO_HAS_BOOST_BIND)
  17. # include <boost/bind/arg.hpp>
  18. #endif // defined(ASIO_HAS_BOOST_BIND)
  19. #include "asio/detail/push_options.hpp"
  20. namespace asio {
  21. namespace placeholders {
  22. #if defined(GENERATING_DOCUMENTATION)
  23. /// An argument placeholder, for use with boost::bind(), that corresponds to
  24. /// the error argument of a handler for any of the asynchronous functions.
  25. unspecified error;
  26. /// An argument placeholder, for use with boost::bind(), that corresponds to
  27. /// the bytes_transferred argument of a handler for asynchronous functions such
  28. /// as asio::basic_stream_socket::async_write_some or
  29. /// asio::async_write.
  30. unspecified bytes_transferred;
  31. /// An argument placeholder, for use with boost::bind(), that corresponds to
  32. /// the iterator argument of a handler for asynchronous functions such as
  33. /// asio::basic_resolver::async_resolve.
  34. unspecified iterator;
  35. /// An argument placeholder, for use with boost::bind(), that corresponds to
  36. /// the signal_number argument of a handler for asynchronous functions such as
  37. /// asio::signal_set::async_wait.
  38. unspecified signal_number;
  39. #elif defined(ASIO_HAS_BOOST_BIND)
  40. # if defined(__BORLANDC__) || defined(__GNUC__)
  41. inline boost::arg<1> error()
  42. {
  43. return boost::arg<1>();
  44. }
  45. inline boost::arg<2> bytes_transferred()
  46. {
  47. return boost::arg<2>();
  48. }
  49. inline boost::arg<2> iterator()
  50. {
  51. return boost::arg<2>();
  52. }
  53. inline boost::arg<2> signal_number()
  54. {
  55. return boost::arg<2>();
  56. }
  57. # else
  58. namespace detail
  59. {
  60. template <int Number>
  61. struct placeholder
  62. {
  63. static boost::arg<Number>& get()
  64. {
  65. static boost::arg<Number> result;
  66. return result;
  67. }
  68. };
  69. }
  70. # if defined(ASIO_MSVC) && (ASIO_MSVC < 1400)
  71. static boost::arg<1>& error
  72. = asio::placeholders::detail::placeholder<1>::get();
  73. static boost::arg<2>& bytes_transferred
  74. = asio::placeholders::detail::placeholder<2>::get();
  75. static boost::arg<2>& iterator
  76. = asio::placeholders::detail::placeholder<2>::get();
  77. static boost::arg<2>& signal_number
  78. = asio::placeholders::detail::placeholder<2>::get();
  79. # else
  80. namespace
  81. {
  82. boost::arg<1>& error
  83. = asio::placeholders::detail::placeholder<1>::get();
  84. boost::arg<2>& bytes_transferred
  85. = asio::placeholders::detail::placeholder<2>::get();
  86. boost::arg<2>& iterator
  87. = asio::placeholders::detail::placeholder<2>::get();
  88. boost::arg<2>& signal_number
  89. = asio::placeholders::detail::placeholder<2>::get();
  90. } // namespace
  91. # endif
  92. # endif
  93. #endif
  94. } // namespace placeholders
  95. } // namespace asio
  96. #include "asio/detail/pop_options.hpp"
  97. #endif // ASIO_PLACEHOLDERS_HPP