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
11#ifndef BOOST_ASIO_PLACEHOLDERS_HPP
12#define BOOST_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 <boost/asio/detail/config.hpp>
19
20#if defined(BOOST_ASIO_HAS_BOOST_BIND)
21# include <boost/bind/arg.hpp>
22#endif // defined(BOOST_ASIO_HAS_BOOST_BIND)
23
24#include <boost/asio/detail/push_options.hpp>
25
26namespace boost {
27namespace asio {
28namespace placeholders {
29
30#if defined(GENERATING_DOCUMENTATION)
31
32/// An argument placeholder, for use with boost::bind(), that corresponds to
33/// the error argument of a handler for any of the asynchronous functions.
34unspecified error;
35
36/// An argument placeholder, for use with boost::bind(), that corresponds to
37/// the bytes_transferred argument of a handler for asynchronous functions such
38/// as boost::asio::basic_stream_socket::async_write_some or
39/// boost::asio::async_write.
40unspecified bytes_transferred;
41
42/// An argument placeholder, for use with boost::bind(), that corresponds to
43/// the iterator argument of a handler for asynchronous functions such as
44/// boost::asio::basic_resolver::async_resolve.
45unspecified iterator;
46
47/// An argument placeholder, for use with boost::bind(), that corresponds to
48/// the signal_number argument of a handler for asynchronous functions such as
49/// boost::asio::signal_set::async_wait.
50unspecified signal_number;
51
52#elif defined(BOOST_ASIO_HAS_BOOST_BIND)
53# if defined(__BORLANDC__) || defined(__GNUC__)
54
55inline boost::arg<1> error()
56{
57 return boost::arg<1>();
58}
59
60inline boost::arg<2> bytes_transferred()
61{
62 return boost::arg<2>();
63}
64
65inline boost::arg<2> iterator()
66{
67 return boost::arg<2>();
68}
69
70inline boost::arg<2> signal_number()
71{
72 return boost::arg<2>();
73}
74
75# else
76
77namespace detail
78{
79 template <int Number>
80 struct placeholder
81 {
82 static boost::arg<Number>& get()
83 {
84 static boost::arg<Number> result;
85 return result;
86 }
87 };
88}
89
90# if defined(BOOST_ASIO_MSVC) && (BOOST_ASIO_MSVC < 1400)
91
92static boost::arg<1>& error
93 = boost::asio::placeholders::detail::placeholder<1>::get();
94static boost::arg<2>& bytes_transferred
95 = boost::asio::placeholders::detail::placeholder<2>::get();
96static boost::arg<2>& iterator
97 = boost::asio::placeholders::detail::placeholder<2>::get();
98static boost::arg<2>& signal_number
99 = boost::asio::placeholders::detail::placeholder<2>::get();
100
101# else
102
103namespace
104{
105 boost::arg<1>& error
106 = boost::asio::placeholders::detail::placeholder<1>::get();
107 boost::arg<2>& bytes_transferred
108 = boost::asio::placeholders::detail::placeholder<2>::get();
109 boost::arg<2>& iterator
110 = boost::asio::placeholders::detail::placeholder<2>::get();
111 boost::arg<2>& signal_number
112 = boost::asio::placeholders::detail::placeholder<2>::get();
113} // namespace
114
115# endif
116# endif
117#endif
118
119} // namespace placeholders
120} // namespace asio
121} // namespace boost
122
123#include <boost/asio/detail/pop_options.hpp>
124
125#endif // BOOST_ASIO_PLACEHOLDERS_HPP
126