1 //
2 // uses_executor.hpp
3 // ~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2020 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_USES_EXECUTOR_HPP
12 #define BOOST_ASIO_USES_EXECUTOR_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 #include <boost/asio/detail/type_traits.hpp>
20 
21 #include <boost/asio/detail/push_options.hpp>
22 
23 namespace boost {
24 namespace asio {
25 
26 /// A special type, similar to std::nothrow_t, used to disambiguate
27 /// constructors that accept executor arguments.
28 /**
29  * The executor_arg_t struct is an empty structure type used as a unique type
30  * to disambiguate constructor and function overloading. Specifically, some
31  * types have constructors with executor_arg_t as the first argument,
32  * immediately followed by an argument of a type that satisfies the Executor
33  * type requirements.
34  */
35 struct executor_arg_t
36 {
37   /// Constructor.
executor_arg_tboost::asio::executor_arg_t38   BOOST_ASIO_CONSTEXPR executor_arg_t() BOOST_ASIO_NOEXCEPT
39   {
40   }
41 };
42 
43 /// A special value, similar to std::nothrow, used to disambiguate constructors
44 /// that accept executor arguments.
45 /**
46  * See boost::asio::executor_arg_t and boost::asio::uses_executor
47  * for more information.
48  */
49 #if defined(BOOST_ASIO_HAS_CONSTEXPR) || defined(GENERATING_DOCUMENTATION)
50 constexpr executor_arg_t executor_arg;
51 #elif defined(BOOST_ASIO_MSVC)
52 __declspec(selectany) executor_arg_t executor_arg;
53 #endif
54 
55 /// The uses_executor trait detects whether a type T has an associated executor
56 /// that is convertible from type Executor.
57 /**
58  * Meets the BinaryTypeTrait requirements. The Asio library provides a
59  * definition that is derived from false_type. A program may specialize this
60  * template to derive from true_type for a user-defined type T that can be
61  * constructed with an executor, where the first argument of a constructor has
62  * type executor_arg_t and the second argument is convertible from type
63  * Executor.
64  */
65 template <typename T, typename Executor>
66 struct uses_executor : false_type {};
67 
68 } // namespace asio
69 } // namespace boost
70 
71 #include <boost/asio/detail/pop_options.hpp>
72 
73 #endif // BOOST_ASIO_USES_EXECUTOR_HPP
74