placeholders.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //
  2. // placeholders.hpp
  3. // ~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2008 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/push_options.hpp>
  16. #include <boost/asio/detail/push_options.hpp>
  17. #include <boost/bind/arg.hpp>
  18. #include <boost/detail/workaround.hpp>
  19. #include <boost/asio/detail/pop_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::basic_resolver::resolve.
  35. unspecified iterator;
  36. #elif defined(__BORLANDC__) || defined(__GNUC__)
  37. inline boost::arg<1> error()
  38. {
  39. return boost::arg<1>();
  40. }
  41. inline boost::arg<2> bytes_transferred()
  42. {
  43. return boost::arg<2>();
  44. }
  45. inline boost::arg<2> iterator()
  46. {
  47. return boost::arg<2>();
  48. }
  49. #else
  50. namespace detail
  51. {
  52. template <int Number>
  53. struct placeholder
  54. {
  55. static boost::arg<Number>& get()
  56. {
  57. static boost::arg<Number> result;
  58. return result;
  59. }
  60. };
  61. }
  62. #if BOOST_WORKAROUND(BOOST_MSVC, < 1400)
  63. static boost::arg<1>& error
  64. = boost::asio::placeholders::detail::placeholder<1>::get();
  65. static boost::arg<2>& bytes_transferred
  66. = boost::asio::placeholders::detail::placeholder<2>::get();
  67. static boost::arg<2>& iterator
  68. = boost::asio::placeholders::detail::placeholder<2>::get();
  69. #else
  70. namespace
  71. {
  72. boost::arg<1>& error
  73. = boost::asio::placeholders::detail::placeholder<1>::get();
  74. boost::arg<2>& bytes_transferred
  75. = boost::asio::placeholders::detail::placeholder<2>::get();
  76. boost::arg<2>& iterator
  77. = boost::asio::placeholders::detail::placeholder<2>::get();
  78. } // namespace
  79. #endif
  80. #endif
  81. } // namespace placeholders
  82. } // namespace asio
  83. } // namespace boost
  84. #include <boost/asio/detail/pop_options.hpp>
  85. #endif // BOOST_ASIO_PLACEHOLDERS_HPP