uses_executor.hpp 2.3 KB

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