placeholders.hpp 2.5 KB

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