placeholders.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //
  2. // placeholders.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 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. #include <boost/bind/arg.hpp>
  17. #include <boost/detail/workaround.hpp>
  18. #include "asio/detail/push_options.hpp"
  19. namespace asio {
  20. namespace placeholders {
  21. #if defined(GENERATING_DOCUMENTATION)
  22. /// An argument placeholder, for use with boost::bind(), that corresponds to
  23. /// the error argument of a handler for any of the asynchronous functions.
  24. unspecified error;
  25. /// An argument placeholder, for use with boost::bind(), that corresponds to
  26. /// the bytes_transferred argument of a handler for asynchronous functions such
  27. /// as asio::basic_stream_socket::async_write_some or
  28. /// asio::async_write.
  29. unspecified bytes_transferred;
  30. /// An argument placeholder, for use with boost::bind(), that corresponds to
  31. /// the iterator argument of a handler for asynchronous functions such as
  32. /// asio::basic_resolver::resolve.
  33. unspecified iterator;
  34. #elif defined(__BORLANDC__) || defined(__GNUC__)
  35. inline boost::arg<1> error()
  36. {
  37. return boost::arg<1>();
  38. }
  39. inline boost::arg<2> bytes_transferred()
  40. {
  41. return boost::arg<2>();
  42. }
  43. inline boost::arg<2> iterator()
  44. {
  45. return boost::arg<2>();
  46. }
  47. #else
  48. namespace detail
  49. {
  50. template <int Number>
  51. struct placeholder
  52. {
  53. static boost::arg<Number>& get()
  54. {
  55. static boost::arg<Number> result;
  56. return result;
  57. }
  58. };
  59. }
  60. #if BOOST_WORKAROUND(BOOST_MSVC, < 1400)
  61. static boost::arg<1>& error
  62. = asio::placeholders::detail::placeholder<1>::get();
  63. static boost::arg<2>& bytes_transferred
  64. = asio::placeholders::detail::placeholder<2>::get();
  65. static boost::arg<2>& iterator
  66. = asio::placeholders::detail::placeholder<2>::get();
  67. #else
  68. namespace
  69. {
  70. boost::arg<1>& error
  71. = asio::placeholders::detail::placeholder<1>::get();
  72. boost::arg<2>& bytes_transferred
  73. = asio::placeholders::detail::placeholder<2>::get();
  74. boost::arg<2>& iterator
  75. = asio::placeholders::detail::placeholder<2>::get();
  76. } // namespace
  77. #endif
  78. #endif
  79. } // namespace placeholders
  80. } // namespace asio
  81. #include "asio/detail/pop_options.hpp"
  82. #endif // ASIO_PLACEHOLDERS_HPP