uses_executor.hpp 2.0 KB

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