operation_state.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //
  2. // execution/operation_state.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 BOOST_ASIO_EXECUTION_OPERATION_STATE_HPP
  11. #define BOOST_ASIO_EXECUTION_OPERATION_STATE_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. #if !defined(BOOST_ASIO_NO_DEPRECATED)
  17. #include <boost/asio/detail/type_traits.hpp>
  18. #include <boost/asio/execution/start.hpp>
  19. #if defined(BOOST_ASIO_HAS_DEDUCED_START_FREE_TRAIT) \
  20. && defined(BOOST_ASIO_HAS_DEDUCED_START_MEMBER_TRAIT)
  21. # define BOOST_ASIO_HAS_DEDUCED_EXECUTION_IS_OPERATION_STATE_TRAIT 1
  22. #endif // defined(BOOST_ASIO_HAS_DEDUCED_START_FREE_TRAIT)
  23. // && defined(BOOST_ASIO_HAS_DEDUCED_START_MEMBER_TRAIT)
  24. #include <boost/asio/detail/push_options.hpp>
  25. namespace boost {
  26. namespace asio {
  27. namespace execution {
  28. namespace detail {
  29. template <typename T>
  30. struct is_operation_state_base :
  31. integral_constant<bool,
  32. is_destructible<T>::value
  33. && is_object<T>::value
  34. >
  35. {
  36. };
  37. } // namespace detail
  38. /// The is_operation_state trait detects whether a type T satisfies the
  39. /// execution::operation_state concept.
  40. /**
  41. * Class template @c is_operation_state is a type trait that is derived from
  42. * @c true_type if the type @c T meets the concept definition for an
  43. * @c operation_state, otherwise @c false_type.
  44. */
  45. template <typename T>
  46. struct is_operation_state :
  47. #if defined(GENERATING_DOCUMENTATION)
  48. integral_constant<bool, automatically_determined>
  49. #else // defined(GENERATING_DOCUMENTATION)
  50. conditional<
  51. can_start<typename add_lvalue_reference<T>::type>::value
  52. && is_nothrow_start<typename add_lvalue_reference<T>::type>::value,
  53. detail::is_operation_state_base<T>,
  54. false_type
  55. >::type
  56. #endif // defined(GENERATING_DOCUMENTATION)
  57. {
  58. };
  59. #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
  60. template <typename T>
  61. BOOST_ASIO_CONSTEXPR const bool is_operation_state_v =
  62. is_operation_state<T>::value;
  63. #endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
  64. #if defined(BOOST_ASIO_HAS_CONCEPTS)
  65. template <typename T>
  66. BOOST_ASIO_CONCEPT operation_state = is_operation_state<T>::value;
  67. #define BOOST_ASIO_EXECUTION_OPERATION_STATE \
  68. ::boost::asio::execution::operation_state
  69. #else // defined(BOOST_ASIO_HAS_CONCEPTS)
  70. #define BOOST_ASIO_EXECUTION_OPERATION_STATE typename
  71. #endif // defined(BOOST_ASIO_HAS_CONCEPTS)
  72. } // namespace execution
  73. } // namespace asio
  74. } // namespace boost
  75. #include <boost/asio/detail/pop_options.hpp>
  76. #endif // !defined(BOOST_ASIO_NO_DEPRECATED)
  77. #endif // BOOST_ASIO_EXECUTION_OPERATION_STATE_HPP