]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/boost/asio/execution/blocking_adaptation.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / asio / execution / blocking_adaptation.hpp
index 157953e74376855b660c1d9dc7d7acba960552f9..69101a0fb0e8eeee8689d8c7a7618cee1ee48a71 100644 (file)
@@ -2,7 +2,7 @@
 // execution/blocking_adaptation.hpp
 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 //
-// Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
 //
 // Distributed under the Boost Software License, Version 1.0. (See accompanying
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -167,8 +167,18 @@ struct blocking_adaptation_t
 #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
   template <typename T>
   BOOST_ASIO_STATIC_CONSTEXPR(bool,
-    is_applicable_property_v = is_executor<T>::value
-      || is_sender<T>::value || is_scheduler<T>::value);
+    is_applicable_property_v = (
+      is_executor<T>::value
+        || conditional<
+            is_executor<T>::value,
+            false_type,
+            is_sender<T>
+          >::type::value
+        || conditional<
+            is_executor<T>::value,
+            false_type,
+            is_scheduler<T>
+          >::type::value));
 #endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
 
   BOOST_ASIO_STATIC_CONSTEXPR(bool, is_requirable = false);
@@ -193,20 +203,74 @@ struct blocking_adaptation_t
   {
   }
 
+  template <typename T>
+  struct proxy
+  {
+#if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
+    struct type
+    {
+      template <typename P>
+      auto query(BOOST_ASIO_MOVE_ARG(P) p) const
+        noexcept(
+          noexcept(
+            declval<typename conditional<true, T, P>::type>().query(
+              BOOST_ASIO_MOVE_CAST(P)(p))
+          )
+        )
+        -> decltype(
+          declval<typename conditional<true, T, P>::type>().query(
+            BOOST_ASIO_MOVE_CAST(P)(p))
+        );
+    };
+#else // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
+    typedef T type;
+#endif // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
+  };
+
+  template <typename T>
+  struct static_proxy
+  {
+#if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
+    struct type
+    {
+      template <typename P>
+      static constexpr auto query(BOOST_ASIO_MOVE_ARG(P) p)
+        noexcept(
+          noexcept(
+            conditional<true, T, P>::type::query(BOOST_ASIO_MOVE_CAST(P)(p))
+          )
+        )
+        -> decltype(
+          conditional<true, T, P>::type::query(BOOST_ASIO_MOVE_CAST(P)(p))
+        )
+      {
+        return T::query(BOOST_ASIO_MOVE_CAST(P)(p));
+      }
+    };
+#else // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
+    typedef T type;
+#endif // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
+  };
+
+  template <typename T>
+  struct query_member :
+    traits::query_member<typename proxy<T>::type, blocking_adaptation_t> {};
+
+  template <typename T>
+  struct query_static_constexpr_member :
+    traits::query_static_constexpr_member<
+      typename static_proxy<T>::type, blocking_adaptation_t> {};
+
 #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
   && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
   template <typename T>
   static BOOST_ASIO_CONSTEXPR
-  typename traits::query_static_constexpr_member<
-      T, blocking_adaptation_t>::result_type
+  typename query_static_constexpr_member<T>::result_type
   static_query()
     BOOST_ASIO_NOEXCEPT_IF((
-      traits::query_static_constexpr_member<
-        T, blocking_adaptation_t
-      >::is_noexcept))
+      query_static_constexpr_member<T>::is_noexcept))
   {
-    return traits::query_static_constexpr_member<
-        T, blocking_adaptation_t>::value();
+    return query_static_constexpr_member<T>::value();
   }
 
   template <typename T>
@@ -214,10 +278,13 @@ struct blocking_adaptation_t
   typename traits::static_query<T, disallowed_t>::result_type
   static_query(
       typename enable_if<
-        !traits::query_static_constexpr_member<
-            T, blocking_adaptation_t>::is_valid
-          && !traits::query_member<T, blocking_adaptation_t>::is_valid
-          && traits::static_query<T, disallowed_t>::is_valid
+        !query_static_constexpr_member<T>::is_valid
+      >::type* = 0,
+      typename enable_if<
+        !query_member<T>::is_valid
+      >::type* = 0,
+      typename enable_if<
+        traits::static_query<T, disallowed_t>::is_valid
       >::type* = 0) BOOST_ASIO_NOEXCEPT
   {
     return traits::static_query<T, disallowed_t>::value();
@@ -228,11 +295,16 @@ struct blocking_adaptation_t
   typename traits::static_query<T, allowed_t>::result_type
   static_query(
       typename enable_if<
-        !traits::query_static_constexpr_member<
-            T, blocking_adaptation_t>::is_valid
-          && !traits::query_member<T, blocking_adaptation_t>::is_valid
-          && !traits::static_query<T, disallowed_t>::is_valid
-          && traits::static_query<T, allowed_t>::is_valid
+        !query_static_constexpr_member<T>::is_valid
+      >::type* = 0,
+      typename enable_if<
+        !query_member<T>::is_valid
+      >::type* = 0,
+      typename enable_if<
+        !traits::static_query<T, disallowed_t>::is_valid
+      >::type* = 0,
+      typename enable_if<
+        traits::static_query<T, allowed_t>::is_valid
       >::type* = 0) BOOST_ASIO_NOEXCEPT
   {
     return traits::static_query<T, allowed_t>::value();
@@ -290,7 +362,9 @@ struct blocking_adaptation_t
       const Executor& ex, convertible_from_blocking_adaptation_t,
       typename enable_if<
         !can_query<const Executor&, disallowed_t>::value
-          && can_query<const Executor&, allowed_t>::value
+      >::type* = 0,
+      typename enable_if<
+        can_query<const Executor&, allowed_t>::value
       >::type* = 0)
 #if !defined(__clang__) // Clang crashes if noexcept is used here.
 #if defined(BOOST_ASIO_MSVC) // Visual C++ wants the type to be qualified.
@@ -345,8 +419,18 @@ struct disallowed_t
 #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
   template <typename T>
   BOOST_ASIO_STATIC_CONSTEXPR(bool,
-    is_applicable_property_v = is_executor<T>::value
-      || is_sender<T>::value || is_scheduler<T>::value);
+    is_applicable_property_v = (
+      is_executor<T>::value
+        || conditional<
+            is_executor<T>::value,
+            false_type,
+            is_sender<T>
+          >::type::value
+        || conditional<
+            is_executor<T>::value,
+            false_type,
+            is_scheduler<T>
+          >::type::value));
 #endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
 
   BOOST_ASIO_STATIC_CONSTEXPR(bool, is_requirable = true);
@@ -357,25 +441,43 @@ struct disallowed_t
   {
   }
 
+  template <typename T>
+  struct query_member :
+    traits::query_member<
+      typename blocking_adaptation_t<I>::template proxy<T>::type,
+        disallowed_t> {};
+
+  template <typename T>
+  struct query_static_constexpr_member :
+    traits::query_static_constexpr_member<
+      typename blocking_adaptation_t<I>::template static_proxy<T>::type,
+        disallowed_t> {};
+
 #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
   && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
   template <typename T>
   static BOOST_ASIO_CONSTEXPR
-  typename traits::query_static_constexpr_member<T, disallowed_t>::result_type
+  typename query_static_constexpr_member<T>::result_type
   static_query()
     BOOST_ASIO_NOEXCEPT_IF((
-      traits::query_static_constexpr_member<T, disallowed_t>::is_noexcept))
+      query_static_constexpr_member<T>::is_noexcept))
   {
-    return traits::query_static_constexpr_member<T, disallowed_t>::value();
+    return query_static_constexpr_member<T>::value();
   }
 
   template <typename T>
   static BOOST_ASIO_CONSTEXPR disallowed_t static_query(
       typename enable_if<
-        !traits::query_static_constexpr_member<T, disallowed_t>::is_valid
-          && !traits::query_member<T, disallowed_t>::is_valid
-          && !traits::query_free<T, disallowed_t>::is_valid
-          && !can_query<T, allowed_t<I> >::value
+        !query_static_constexpr_member<T>::is_valid
+      >::type* = 0,
+      typename enable_if<
+        !query_member<T>::is_valid
+      >::type* = 0,
+      typename enable_if<
+        !traits::query_free<T, disallowed_t>::is_valid
+      >::type* = 0,
+      typename enable_if<
+        !can_query<T, allowed_t<I> >::value
       >::type* = 0) BOOST_ASIO_NOEXCEPT
   {
     return disallowed_t();
@@ -529,8 +631,18 @@ struct allowed_t
 #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
   template <typename T>
   BOOST_ASIO_STATIC_CONSTEXPR(bool,
-    is_applicable_property_v = is_executor<T>::value
-      || is_sender<T>::value || is_scheduler<T>::value);
+    is_applicable_property_v = (
+      is_executor<T>::value
+        || conditional<
+            is_executor<T>::value,
+            false_type,
+            is_sender<T>
+          >::type::value
+        || conditional<
+            is_executor<T>::value,
+            false_type,
+            is_scheduler<T>
+          >::type::value));
 #endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
 
   BOOST_ASIO_STATIC_CONSTEXPR(bool, is_requirable = true);
@@ -541,16 +653,28 @@ struct allowed_t
   {
   }
 
+  template <typename T>
+  struct query_member :
+    traits::query_member<
+      typename blocking_adaptation_t<I>::template proxy<T>::type,
+        allowed_t> {};
+
+  template <typename T>
+  struct query_static_constexpr_member :
+    traits::query_static_constexpr_member<
+      typename blocking_adaptation_t<I>::template static_proxy<T>::type,
+        allowed_t> {};
+
 #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
   && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
   template <typename T>
   static BOOST_ASIO_CONSTEXPR
-  typename traits::query_static_constexpr_member<T, allowed_t>::result_type
+  typename query_static_constexpr_member<T>::result_type
   static_query()
     BOOST_ASIO_NOEXCEPT_IF((
-      traits::query_static_constexpr_member<T, allowed_t>::is_noexcept))
+      query_static_constexpr_member<T>::is_noexcept))
   {
-    return traits::query_static_constexpr_member<T, allowed_t>::value();
+    return query_static_constexpr_member<T>::value();
   }
 
   template <typename E, typename T = decltype(allowed_t::static_query<E>())>
@@ -674,8 +798,16 @@ template <typename T>
 struct is_applicable_property<T, execution::blocking_adaptation_t>
   : integral_constant<bool,
       execution::is_executor<T>::value
-        || execution::is_sender<T>::value
-        || execution::is_scheduler<T>::value>
+        || conditional<
+            execution::is_executor<T>::value,
+            false_type,
+            execution::is_sender<T>
+          >::type::value
+        || conditional<
+            execution::is_executor<T>::value,
+            false_type,
+            execution::is_scheduler<T>
+          >::type::value>
 {
 };
 
@@ -683,8 +815,16 @@ template <typename T>
 struct is_applicable_property<T, execution::blocking_adaptation_t::disallowed_t>
   : integral_constant<bool,
       execution::is_executor<T>::value
-        || execution::is_sender<T>::value
-        || execution::is_scheduler<T>::value>
+        || conditional<
+            execution::is_executor<T>::value,
+            false_type,
+            execution::is_sender<T>
+          >::type::value
+        || conditional<
+            execution::is_executor<T>::value,
+            false_type,
+            execution::is_scheduler<T>
+          >::type::value>
 {
 };
 
@@ -692,8 +832,16 @@ template <typename T>
 struct is_applicable_property<T, execution::blocking_adaptation_t::allowed_t>
   : integral_constant<bool,
       execution::is_executor<T>::value
-        || execution::is_sender<T>::value
-        || execution::is_scheduler<T>::value>
+        || conditional<
+            execution::is_executor<T>::value,
+            false_type,
+            execution::is_sender<T>
+          >::type::value
+        || conditional<
+            execution::is_executor<T>::value,
+            false_type,
+            execution::is_scheduler<T>
+          >::type::value>
 {
 };
 
@@ -738,30 +886,30 @@ struct query_free_default<T, execution::blocking_adaptation_t,
 template <typename T>
 struct static_query<T, execution::blocking_adaptation_t,
   typename enable_if<
-    traits::query_static_constexpr_member<T,
-      execution::blocking_adaptation_t>::is_valid
+    execution::detail::blocking_adaptation_t<0>::
+      query_static_constexpr_member<T>::is_valid
   >::type>
 {
   BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
   BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
 
-  typedef typename traits::query_static_constexpr_member<T,
-    execution::blocking_adaptation_t>::result_type result_type;
+  typedef typename execution::detail::blocking_adaptation_t<0>::
+    query_static_constexpr_member<T>::result_type result_type;
 
   static BOOST_ASIO_CONSTEXPR result_type value()
   {
-    return traits::query_static_constexpr_member<T,
-      execution::blocking_adaptation_t>::value();
+    return execution::detail::blocking_adaptation_t<0>::
+      query_static_constexpr_member<T>::value();
   }
 };
 
 template <typename T>
 struct static_query<T, execution::blocking_adaptation_t,
   typename enable_if<
-    !traits::query_static_constexpr_member<T,
-        execution::blocking_adaptation_t>::is_valid
-      && !traits::query_member<T,
-        execution::blocking_adaptation_t>::is_valid
+    !execution::detail::blocking_adaptation_t<0>::
+        query_static_constexpr_member<T>::is_valid
+      && !execution::detail::blocking_adaptation_t<0>::
+        query_member<T>::is_valid
       && traits::static_query<T,
         execution::blocking_adaptation_t::disallowed_t>::is_valid
   >::type>
@@ -782,10 +930,10 @@ struct static_query<T, execution::blocking_adaptation_t,
 template <typename T>
 struct static_query<T, execution::blocking_adaptation_t,
   typename enable_if<
-    !traits::query_static_constexpr_member<T,
-        execution::blocking_adaptation_t>::is_valid
-      && !traits::query_member<T,
-        execution::blocking_adaptation_t>::is_valid
+    !execution::detail::blocking_adaptation_t<0>::
+        query_static_constexpr_member<T>::is_valid
+      && !execution::detail::blocking_adaptation_t<0>::
+        query_member<T>::is_valid
       && !traits::static_query<T,
         execution::blocking_adaptation_t::disallowed_t>::is_valid
       && traits::static_query<T,
@@ -808,30 +956,30 @@ struct static_query<T, execution::blocking_adaptation_t,
 template <typename T>
 struct static_query<T, execution::blocking_adaptation_t::disallowed_t,
   typename enable_if<
-    traits::query_static_constexpr_member<T,
-      execution::blocking_adaptation_t::disallowed_t>::is_valid
+    execution::detail::blocking_adaptation::disallowed_t<0>::
+      query_static_constexpr_member<T>::is_valid
   >::type>
 {
   BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
   BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
 
-  typedef typename traits::query_static_constexpr_member<T,
-    execution::blocking_adaptation_t::disallowed_t>::result_type result_type;
+  typedef typename execution::detail::blocking_adaptation::disallowed_t<0>::
+    query_static_constexpr_member<T>::result_type result_type;
 
   static BOOST_ASIO_CONSTEXPR result_type value()
   {
-    return traits::query_static_constexpr_member<T,
-      execution::blocking_adaptation_t::disallowed_t>::value();
+    return execution::detail::blocking_adaptation::disallowed_t<0>::
+      query_static_constexpr_member<T>::value();
   }
 };
 
 template <typename T>
 struct static_query<T, execution::blocking_adaptation_t::disallowed_t,
   typename enable_if<
-    !traits::query_static_constexpr_member<T,
-        execution::blocking_adaptation_t::disallowed_t>::is_valid
-      && !traits::query_member<T,
-        execution::blocking_adaptation_t::disallowed_t>::is_valid
+    !execution::detail::blocking_adaptation::disallowed_t<0>::
+        query_static_constexpr_member<T>::is_valid
+      && !execution::detail::blocking_adaptation::disallowed_t<0>::
+        query_member<T>::is_valid
       && !traits::query_free<T,
         execution::blocking_adaptation_t::disallowed_t>::is_valid
       && !can_query<T, execution::blocking_adaptation_t::allowed_t>::value
@@ -851,20 +999,20 @@ struct static_query<T, execution::blocking_adaptation_t::disallowed_t,
 template <typename T>
 struct static_query<T, execution::blocking_adaptation_t::allowed_t,
   typename enable_if<
-    traits::query_static_constexpr_member<T,
-      execution::blocking_adaptation_t::allowed_t>::is_valid
+    execution::detail::blocking_adaptation::allowed_t<0>::
+      query_static_constexpr_member<T>::is_valid
   >::type>
 {
   BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
   BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = true);
 
-  typedef typename traits::query_static_constexpr_member<T,
-    execution::blocking_adaptation_t::allowed_t>::result_type result_type;
+  typedef typename execution::detail::blocking_adaptation::allowed_t<0>::
+    query_static_constexpr_member<T>::result_type result_type;
 
   static BOOST_ASIO_CONSTEXPR result_type value()
   {
-    return traits::query_static_constexpr_member<T,
-      execution::blocking_adaptation_t::allowed_t>::value();
+    return execution::detail::blocking_adaptation::allowed_t<0>::
+      query_static_constexpr_member<T>::value();
   }
 };