operation_state.hpp 2.5 KB

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