uses_executor.hpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //
  2. // uses_executor.hpp
  3. // ~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2024 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. constexpr executor_arg_t() 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. constexpr executor_arg_t executor_arg;
  43. /// The uses_executor trait detects whether a type T has an associated executor
  44. /// that is convertible from type Executor.
  45. /**
  46. * Meets the BinaryTypeTrait requirements. The Asio library provides a
  47. * definition that is derived from false_type. A program may specialize this
  48. * template to derive from true_type for a user-defined type T that can be
  49. * constructed with an executor, where the first argument of a constructor has
  50. * type executor_arg_t and the second argument is convertible from type
  51. * Executor.
  52. */
  53. template <typename T, typename Executor>
  54. struct uses_executor : false_type {};
  55. } // namespace asio
  56. } // namespace boost
  57. #include <boost/asio/detail/pop_options.hpp>
  58. #endif // BOOST_ASIO_USES_EXECUTOR_HPP