bulk_execute_free.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //
  2. // traits/bulk_execute_free.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_TRAITS_BULK_EXECUTE_FREE_HPP
  11. #define ASIO_TRAITS_BULK_EXECUTE_FREE_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. #if defined(ASIO_HAS_DECLTYPE) \
  18. && defined(ASIO_HAS_NOEXCEPT) \
  19. && defined(ASIO_HAS_WORKING_EXPRESSION_SFINAE)
  20. # define ASIO_HAS_DEDUCED_BULK_EXECUTE_FREE_TRAIT 1
  21. #endif // defined(ASIO_HAS_DECLTYPE)
  22. // && defined(ASIO_HAS_NOEXCEPT)
  23. // && defined(ASIO_HAS_WORKING_EXPRESSION_SFINAE)
  24. #include "asio/detail/push_options.hpp"
  25. namespace asio {
  26. namespace traits {
  27. template <typename T, typename F, typename N, typename = void>
  28. struct bulk_execute_free_default;
  29. template <typename T, typename F, typename N, typename = void>
  30. struct bulk_execute_free;
  31. } // namespace traits
  32. namespace detail {
  33. struct no_bulk_execute_free
  34. {
  35. ASIO_STATIC_CONSTEXPR(bool, is_valid = false);
  36. ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
  37. };
  38. #if defined(ASIO_HAS_DEDUCED_BULK_EXECUTE_FREE_TRAIT)
  39. template <typename T, typename F, typename N, typename = void>
  40. struct bulk_execute_free_trait : no_bulk_execute_free
  41. {
  42. };
  43. template <typename T, typename F, typename N>
  44. struct bulk_execute_free_trait<T, F, N,
  45. typename void_type<
  46. decltype(bulk_execute(declval<T>(), declval<F>(), declval<N>()))
  47. >::type>
  48. {
  49. ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
  50. using result_type = decltype(
  51. bulk_execute(declval<T>(), declval<F>(), declval<N>()));
  52. ASIO_STATIC_CONSTEXPR(bool, is_noexcept = noexcept(
  53. bulk_execute(declval<T>(), declval<F>(), declval<N>())));
  54. };
  55. #else // defined(ASIO_HAS_DEDUCED_BULK_EXECUTE_FREE_TRAIT)
  56. template <typename T, typename F, typename N, typename = void>
  57. struct bulk_execute_free_trait :
  58. conditional<
  59. is_same<T, typename remove_reference<T>::type>::value
  60. && is_same<F, typename decay<F>::type>::value
  61. && is_same<N, typename decay<N>::type>::value,
  62. typename conditional<
  63. is_same<T, typename add_const<T>::type>::value,
  64. no_bulk_execute_free,
  65. traits::bulk_execute_free<typename add_const<T>::type, F, N>
  66. >::type,
  67. traits::bulk_execute_free<
  68. typename remove_reference<T>::type,
  69. typename decay<F>::type,
  70. typename decay<N>::type>
  71. >::type
  72. {
  73. };
  74. #endif // defined(ASIO_HAS_DEDUCED_BULK_EXECUTE_FREE_TRAIT)
  75. } // namespace detail
  76. namespace traits {
  77. template <typename T, typename F, typename N, typename>
  78. struct bulk_execute_free_default :
  79. detail::bulk_execute_free_trait<T, F, N>
  80. {
  81. };
  82. template <typename T, typename F, typename N, typename>
  83. struct bulk_execute_free :
  84. bulk_execute_free_default<T, F, N>
  85. {
  86. };
  87. } // namespace traits
  88. } // namespace asio
  89. #include "asio/detail/pop_options.hpp"
  90. #endif // ASIO_TRAITS_BULK_EXECUTE_FREE_HPP