1 //
2 // placeholders.hpp
3 // ~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2016 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 
11 #ifndef ASIO_PLACEHOLDERS_HPP
12 #define ASIO_PLACEHOLDERS_HPP
13 
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 
18 #include "asio/detail/config.hpp"
19 
20 #if defined(ASIO_HAS_BOOST_BIND)
21 # include <boost/bind/arg.hpp>
22 #endif // defined(ASIO_HAS_BOOST_BIND)
23 
24 #include "asio/detail/push_options.hpp"
25 
26 namespace asio {
27 namespace placeholders {
28 
29 #if defined(GENERATING_DOCUMENTATION)
30 
31 /// An argument placeholder, for use with boost::bind(), that corresponds to
32 /// the error argument of a handler for any of the asynchronous functions.
33 unspecified error;
34 
35 /// An argument placeholder, for use with boost::bind(), that corresponds to
36 /// the bytes_transferred argument of a handler for asynchronous functions such
37 /// as asio::basic_stream_socket::async_write_some or
38 /// asio::async_write.
39 unspecified bytes_transferred;
40 
41 /// An argument placeholder, for use with boost::bind(), that corresponds to
42 /// the iterator argument of a handler for asynchronous functions such as
43 /// asio::async_connect.
44 unspecified iterator;
45 
46 /// An argument placeholder, for use with boost::bind(), that corresponds to
47 /// the results argument of a handler for asynchronous functions such as
48 /// asio::basic_resolver::async_resolve.
49 unspecified results;
50 
51 /// An argument placeholder, for use with boost::bind(), that corresponds to
52 /// the results argument of a handler for asynchronous functions such as
53 /// asio::async_connect.
54 unspecified endpoint;
55 
56 /// An argument placeholder, for use with boost::bind(), that corresponds to
57 /// the signal_number argument of a handler for asynchronous functions such as
58 /// asio::signal_set::async_wait.
59 unspecified signal_number;
60 
61 #elif defined(ASIO_HAS_BOOST_BIND)
62 # if defined(__BORLANDC__) || defined(__GNUC__)
63 
64 inline boost::arg<1> error()
65 {
66   return boost::arg<1>();
67 }
68 
69 inline boost::arg<2> bytes_transferred()
70 {
71   return boost::arg<2>();
72 }
73 
74 inline boost::arg<2> iterator()
75 {
76   return boost::arg<2>();
77 }
78 
79 inline boost::arg<2> results()
80 {
81   return boost::arg<2>();
82 }
83 
84 inline boost::arg<2> endpoint()
85 {
86   return boost::arg<2>();
87 }
88 
89 inline boost::arg<2> signal_number()
90 {
91   return boost::arg<2>();
92 }
93 
94 # else
95 
96 namespace detail
97 {
98   template <int Number>
99   struct placeholder
100   {
101     static boost::arg<Number>& get()
102     {
103       static boost::arg<Number> result;
104       return result;
105     }
106   };
107 }
108 
109 #  if defined(ASIO_MSVC) && (ASIO_MSVC < 1400)
110 
111 static boost::arg<1>& error
112   = asio::placeholders::detail::placeholder<1>::get();
113 static boost::arg<2>& bytes_transferred
114   = asio::placeholders::detail::placeholder<2>::get();
115 static boost::arg<2>& iterator
116   = asio::placeholders::detail::placeholder<2>::get();
117 static boost::arg<2>& results
118   = asio::placeholders::detail::placeholder<2>::get();
119 static boost::arg<2>& endpoint
120   = asio::placeholders::detail::placeholder<2>::get();
121 static boost::arg<2>& signal_number
122   = asio::placeholders::detail::placeholder<2>::get();
123 
124 #  else
125 
126 namespace
127 {
128   boost::arg<1>& error
129     = asio::placeholders::detail::placeholder<1>::get();
130   boost::arg<2>& bytes_transferred
131     = asio::placeholders::detail::placeholder<2>::get();
132   boost::arg<2>& iterator
133     = asio::placeholders::detail::placeholder<2>::get();
134   boost::arg<2>& results
135     = asio::placeholders::detail::placeholder<2>::get();
136   boost::arg<2>& endpoint
137     = asio::placeholders::detail::placeholder<2>::get();
138   boost::arg<2>& signal_number
139     = asio::placeholders::detail::placeholder<2>::get();
140 } // namespace
141 
142 #  endif
143 # endif
144 #endif
145 
146 } // namespace placeholders
147 } // namespace asio
148 
149 #include "asio/detail/pop_options.hpp"
150 
151 #endif // ASIO_PLACEHOLDERS_HPP
152