operation_state.hpp 2.7 KB

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