Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:43:17

0001 //
0002 // execution/mapping.hpp
0003 // ~~~~~~~~~~~~~~~~~~~~~
0004 //
0005 // Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com)
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 //
0010 
0011 #ifndef BOOST_ASIO_EXECUTION_MAPPING_HPP
0012 #define BOOST_ASIO_EXECUTION_MAPPING_HPP
0013 
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
0017 
0018 #include <boost/asio/detail/config.hpp>
0019 #include <boost/asio/detail/type_traits.hpp>
0020 #include <boost/asio/execution/executor.hpp>
0021 #include <boost/asio/is_applicable_property.hpp>
0022 #include <boost/asio/query.hpp>
0023 #include <boost/asio/traits/query_free.hpp>
0024 #include <boost/asio/traits/query_member.hpp>
0025 #include <boost/asio/traits/query_static_constexpr_member.hpp>
0026 #include <boost/asio/traits/static_query.hpp>
0027 #include <boost/asio/traits/static_require.hpp>
0028 
0029 #include <boost/asio/detail/push_options.hpp>
0030 
0031 namespace boost {
0032 namespace asio {
0033 
0034 #if defined(GENERATING_DOCUMENTATION)
0035 
0036 namespace execution {
0037 
0038 /// A property to describe what guarantees an executor makes about the mapping
0039 /// of execution agents on to threads of execution.
0040 struct mapping_t
0041 {
0042   /// The mapping_t property applies to executors.
0043   template <typename T>
0044   static constexpr bool is_applicable_property_v = is_executor_v<T>;
0045 
0046   /// The top-level mapping_t property cannot be required.
0047   static constexpr bool is_requirable = false;
0048 
0049   /// The top-level mapping_t property cannot be preferred.
0050   static constexpr bool is_preferable = false;
0051 
0052   /// The type returned by queries against an @c any_executor.
0053   typedef mapping_t polymorphic_query_result_type;
0054 
0055   /// A sub-property that indicates that execution agents are mapped on to
0056   /// threads of execution.
0057   struct thread_t
0058   {
0059     /// The mapping_t::thread_t property applies to executors.
0060     template <typename T>
0061     static constexpr bool is_applicable_property_v = is_executor_v<T>;
0062 
0063     /// The mapping_t::thread_t property can be required.
0064     static constexpr bool is_requirable = true;
0065 
0066     /// The mapping_t::thread_t property can be preferred.
0067     static constexpr bool is_preferable = true;
0068 
0069     /// The type returned by queries against an @c any_executor.
0070     typedef mapping_t polymorphic_query_result_type;
0071 
0072     /// Default constructor.
0073     constexpr thread_t();
0074 
0075     /// Get the value associated with a property object.
0076     /**
0077      * @returns thread_t();
0078      */
0079     static constexpr mapping_t value();
0080   };
0081 
0082   /// A sub-property that indicates that execution agents are mapped on to
0083   /// new threads of execution.
0084   struct new_thread_t
0085   {
0086     /// The mapping_t::new_thread_t property applies to executors.
0087     template <typename T>
0088     static constexpr bool is_applicable_property_v = is_executor_v<T>;
0089 
0090     /// The mapping_t::new_thread_t property can be required.
0091     static constexpr bool is_requirable = true;
0092 
0093     /// The mapping_t::new_thread_t property can be preferred.
0094     static constexpr bool is_preferable = true;
0095 
0096     /// The type returned by queries against an @c any_executor.
0097     typedef mapping_t polymorphic_query_result_type;
0098 
0099     /// Default constructor.
0100     constexpr new_thread_t();
0101 
0102     /// Get the value associated with a property object.
0103     /**
0104      * @returns new_thread_t();
0105      */
0106     static constexpr mapping_t value();
0107   };
0108 
0109   /// A sub-property that indicates that the mapping of execution agents is
0110   /// implementation-defined.
0111   struct other_t
0112   {
0113     /// The mapping_t::other_t property applies to executors.
0114     template <typename T>
0115     static constexpr bool is_applicable_property_v = is_executor_v<T>;
0116 
0117     /// The mapping_t::other_t property can be required.
0118     static constexpr bool is_requirable = true;
0119 
0120     /// The mapping_t::other_t property can be preferred.
0121     static constexpr bool is_preferable = true;
0122 
0123     /// The type returned by queries against an @c any_executor.
0124     typedef mapping_t polymorphic_query_result_type;
0125 
0126     /// Default constructor.
0127     constexpr other_t();
0128 
0129     /// Get the value associated with a property object.
0130     /**
0131      * @returns other_t();
0132      */
0133     static constexpr mapping_t value();
0134   };
0135 
0136   /// A special value used for accessing the mapping_t::thread_t property.
0137   static constexpr thread_t thread;
0138 
0139   /// A special value used for accessing the mapping_t::new_thread_t property.
0140   static constexpr new_thread_t new_thread;
0141 
0142   /// A special value used for accessing the mapping_t::other_t property.
0143   static constexpr other_t other;
0144 
0145   /// Default constructor.
0146   constexpr mapping_t();
0147 
0148   /// Construct from a sub-property value.
0149   constexpr mapping_t(thread_t);
0150 
0151   /// Construct from a sub-property value.
0152   constexpr mapping_t(new_thread_t);
0153 
0154   /// Construct from a sub-property value.
0155   constexpr mapping_t(other_t);
0156 
0157   /// Compare property values for equality.
0158   friend constexpr bool operator==(
0159       const mapping_t& a, const mapping_t& b) noexcept;
0160 
0161   /// Compare property values for inequality.
0162   friend constexpr bool operator!=(
0163       const mapping_t& a, const mapping_t& b) noexcept;
0164 };
0165 
0166 /// A special value used for accessing the mapping_t property.
0167 constexpr mapping_t mapping;
0168 
0169 } // namespace execution
0170 
0171 #else // defined(GENERATING_DOCUMENTATION)
0172 
0173 namespace execution {
0174 namespace detail {
0175 namespace mapping {
0176 
0177 template <int I> struct thread_t;
0178 template <int I> struct new_thread_t;
0179 template <int I> struct other_t;
0180 
0181 } // namespace mapping
0182 
0183 template <int I = 0>
0184 struct mapping_t
0185 {
0186 #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
0187   template <typename T>
0188   static constexpr bool is_applicable_property_v = is_executor<T>::value;
0189 #endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
0190 
0191   static constexpr bool is_requirable = false;
0192   static constexpr bool is_preferable = false;
0193   typedef mapping_t polymorphic_query_result_type;
0194 
0195   typedef detail::mapping::thread_t<I> thread_t;
0196   typedef detail::mapping::new_thread_t<I> new_thread_t;
0197   typedef detail::mapping::other_t<I> other_t;
0198 
0199   constexpr mapping_t()
0200     : value_(-1)
0201   {
0202   }
0203 
0204   constexpr mapping_t(thread_t)
0205     : value_(0)
0206   {
0207   }
0208 
0209   constexpr mapping_t(new_thread_t)
0210     : value_(1)
0211   {
0212   }
0213 
0214   constexpr mapping_t(other_t)
0215     : value_(2)
0216   {
0217   }
0218 
0219   template <typename T>
0220   struct proxy
0221   {
0222 #if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
0223     struct type
0224     {
0225       template <typename P>
0226       auto query(P&& p) const
0227         noexcept(
0228           noexcept(
0229             declval<conditional_t<true, T, P>>().query(static_cast<P&&>(p))
0230           )
0231         )
0232         -> decltype(
0233           declval<conditional_t<true, T, P>>().query(static_cast<P&&>(p))
0234         );
0235     };
0236 #else // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
0237     typedef T type;
0238 #endif // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
0239   };
0240 
0241   template <typename T>
0242   struct static_proxy
0243   {
0244 #if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
0245     struct type
0246     {
0247       template <typename P>
0248       static constexpr auto query(P&& p)
0249         noexcept(
0250           noexcept(
0251             conditional_t<true, T, P>::query(static_cast<P&&>(p))
0252           )
0253         )
0254         -> decltype(
0255           conditional_t<true, T, P>::query(static_cast<P&&>(p))
0256         )
0257       {
0258         return T::query(static_cast<P&&>(p));
0259       }
0260     };
0261 #else // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
0262     typedef T type;
0263 #endif // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
0264   };
0265 
0266   template <typename T>
0267   struct query_member :
0268     traits::query_member<typename proxy<T>::type, mapping_t> {};
0269 
0270   template <typename T>
0271   struct query_static_constexpr_member :
0272     traits::query_static_constexpr_member<
0273       typename static_proxy<T>::type, mapping_t> {};
0274 
0275 #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
0276   && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0277   template <typename T>
0278   static constexpr
0279   typename query_static_constexpr_member<T>::result_type
0280   static_query()
0281     noexcept(query_static_constexpr_member<T>::is_noexcept)
0282   {
0283     return query_static_constexpr_member<T>::value();
0284   }
0285 
0286   template <typename T>
0287   static constexpr
0288   typename traits::static_query<T, thread_t>::result_type
0289   static_query(
0290       enable_if_t<
0291         !query_static_constexpr_member<T>::is_valid
0292       >* = 0,
0293       enable_if_t<
0294         !query_member<T>::is_valid
0295       >* = 0,
0296       enable_if_t<
0297         traits::static_query<T, thread_t>::is_valid
0298       >* = 0) noexcept
0299   {
0300     return traits::static_query<T, thread_t>::value();
0301   }
0302 
0303   template <typename T>
0304   static constexpr
0305   typename traits::static_query<T, new_thread_t>::result_type
0306   static_query(
0307       enable_if_t<
0308         !query_static_constexpr_member<T>::is_valid
0309       >* = 0,
0310       enable_if_t<
0311         !query_member<T>::is_valid
0312       >* = 0,
0313       enable_if_t<
0314         !traits::static_query<T, thread_t>::is_valid
0315       >* = 0,
0316       enable_if_t<
0317         traits::static_query<T, new_thread_t>::is_valid
0318       >* = 0) noexcept
0319   {
0320     return traits::static_query<T, new_thread_t>::value();
0321   }
0322 
0323   template <typename T>
0324   static constexpr
0325   typename traits::static_query<T, other_t>::result_type
0326   static_query(
0327       enable_if_t<
0328         !query_static_constexpr_member<T>::is_valid
0329       >* = 0,
0330       enable_if_t<
0331         !query_member<T>::is_valid
0332       >* = 0,
0333       enable_if_t<
0334         !traits::static_query<T, thread_t>::is_valid
0335       >* = 0,
0336       enable_if_t<
0337         !traits::static_query<T, new_thread_t>::is_valid
0338       >* = 0,
0339       enable_if_t<
0340         traits::static_query<T, other_t>::is_valid
0341       >* = 0) noexcept
0342   {
0343     return traits::static_query<T, other_t>::value();
0344   }
0345 
0346   template <typename E, typename T = decltype(mapping_t::static_query<E>())>
0347   static constexpr const T static_query_v
0348     = mapping_t::static_query<E>();
0349 #endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
0350        //   && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0351 
0352   friend constexpr bool operator==(
0353       const mapping_t& a, const mapping_t& b)
0354   {
0355     return a.value_ == b.value_;
0356   }
0357 
0358   friend constexpr bool operator!=(
0359       const mapping_t& a, const mapping_t& b)
0360   {
0361     return a.value_ != b.value_;
0362   }
0363 
0364   struct convertible_from_mapping_t
0365   {
0366     constexpr convertible_from_mapping_t(mapping_t) {}
0367   };
0368 
0369   template <typename Executor>
0370   friend constexpr mapping_t query(
0371       const Executor& ex, convertible_from_mapping_t,
0372       enable_if_t<
0373         can_query<const Executor&, thread_t>::value
0374       >* = 0)
0375 #if !defined(__clang__) // Clang crashes if noexcept is used here.
0376 #if defined(BOOST_ASIO_MSVC) // Visual C++ wants the type to be qualified.
0377     noexcept(is_nothrow_query<const Executor&, mapping_t<>::thread_t>::value)
0378 #else // defined(BOOST_ASIO_MSVC)
0379     noexcept(is_nothrow_query<const Executor&, thread_t>::value)
0380 #endif // defined(BOOST_ASIO_MSVC)
0381 #endif // !defined(__clang__)
0382   {
0383     return boost::asio::query(ex, thread_t());
0384   }
0385 
0386   template <typename Executor>
0387   friend constexpr mapping_t query(
0388       const Executor& ex, convertible_from_mapping_t,
0389       enable_if_t<
0390         !can_query<const Executor&, thread_t>::value
0391       >* = 0,
0392       enable_if_t<
0393         can_query<const Executor&, new_thread_t>::value
0394       >* = 0)
0395 #if !defined(__clang__) // Clang crashes if noexcept is used here.
0396 #if defined(BOOST_ASIO_MSVC) // Visual C++ wants the type to be qualified.
0397     noexcept(
0398       is_nothrow_query<const Executor&, mapping_t<>::new_thread_t>::value)
0399 #else // defined(BOOST_ASIO_MSVC)
0400     noexcept(is_nothrow_query<const Executor&, new_thread_t>::value)
0401 #endif // defined(BOOST_ASIO_MSVC)
0402 #endif // !defined(__clang__)
0403   {
0404     return boost::asio::query(ex, new_thread_t());
0405   }
0406 
0407   template <typename Executor>
0408   friend constexpr mapping_t query(
0409       const Executor& ex, convertible_from_mapping_t,
0410       enable_if_t<
0411         !can_query<const Executor&, thread_t>::value
0412       >* = 0,
0413       enable_if_t<
0414         !can_query<const Executor&, new_thread_t>::value
0415       >* = 0,
0416       enable_if_t<
0417         can_query<const Executor&, other_t>::value
0418       >* = 0)
0419 #if !defined(__clang__) // Clang crashes if noexcept is used here.
0420 #if defined(BOOST_ASIO_MSVC) // Visual C++ wants the type to be qualified.
0421     noexcept(is_nothrow_query<const Executor&, mapping_t<>::other_t>::value)
0422 #else // defined(BOOST_ASIO_MSVC)
0423     noexcept(is_nothrow_query<const Executor&, other_t>::value)
0424 #endif // defined(BOOST_ASIO_MSVC)
0425 #endif // !defined(__clang__)
0426   {
0427     return boost::asio::query(ex, other_t());
0428   }
0429 
0430   BOOST_ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(thread_t, thread);
0431   BOOST_ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(new_thread_t, new_thread);
0432   BOOST_ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(other_t, other);
0433 
0434 private:
0435   int value_;
0436 };
0437 
0438 #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
0439   && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0440 template <int I> template <typename E, typename T>
0441 const T mapping_t<I>::static_query_v;
0442 #endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
0443        //   && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0444 
0445 template <int I>
0446 const typename mapping_t<I>::thread_t mapping_t<I>::thread;
0447 
0448 template <int I>
0449 const typename mapping_t<I>::new_thread_t mapping_t<I>::new_thread;
0450 
0451 template <int I>
0452 const typename mapping_t<I>::other_t mapping_t<I>::other;
0453 
0454 namespace mapping {
0455 
0456 template <int I = 0>
0457 struct thread_t
0458 {
0459 #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
0460   template <typename T>
0461   static constexpr bool is_applicable_property_v = is_executor<T>::value;
0462 #endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
0463 
0464   static constexpr bool is_requirable = true;
0465   static constexpr bool is_preferable = true;
0466   typedef mapping_t<I> polymorphic_query_result_type;
0467 
0468   constexpr thread_t()
0469   {
0470   }
0471 
0472   template <typename T>
0473   struct query_member :
0474     traits::query_member<
0475       typename mapping_t<I>::template proxy<T>::type, thread_t> {};
0476 
0477   template <typename T>
0478   struct query_static_constexpr_member :
0479     traits::query_static_constexpr_member<
0480       typename mapping_t<I>::template static_proxy<T>::type, thread_t> {};
0481 
0482 #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
0483   && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0484   template <typename T>
0485   static constexpr
0486   typename query_static_constexpr_member<T>::result_type
0487   static_query()
0488     noexcept(query_static_constexpr_member<T>::is_noexcept)
0489   {
0490     return query_static_constexpr_member<T>::value();
0491   }
0492 
0493   template <typename T>
0494   static constexpr thread_t static_query(
0495       enable_if_t<
0496         !query_static_constexpr_member<T>::is_valid
0497       >* = 0,
0498       enable_if_t<
0499         !query_member<T>::is_valid
0500       >* = 0,
0501       enable_if_t<
0502         !traits::query_free<T, thread_t>::is_valid
0503       >* = 0,
0504       enable_if_t<
0505         !can_query<T, new_thread_t<I>>::value
0506       >* = 0,
0507       enable_if_t<
0508         !can_query<T, other_t<I>>::value
0509       >* = 0) noexcept
0510   {
0511     return thread_t();
0512   }
0513 
0514   template <typename E, typename T = decltype(thread_t::static_query<E>())>
0515   static constexpr const T static_query_v
0516     = thread_t::static_query<E>();
0517 #endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
0518        //   && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0519 
0520   static constexpr mapping_t<I> value()
0521   {
0522     return thread_t();
0523   }
0524 
0525   friend constexpr bool operator==(const thread_t&, const thread_t&)
0526   {
0527     return true;
0528   }
0529 
0530   friend constexpr bool operator!=(const thread_t&, const thread_t&)
0531   {
0532     return false;
0533   }
0534 
0535   friend constexpr bool operator==(const thread_t&, const new_thread_t<I>&)
0536   {
0537     return false;
0538   }
0539 
0540   friend constexpr bool operator!=(const thread_t&, const new_thread_t<I>&)
0541   {
0542     return true;
0543   }
0544 
0545   friend constexpr bool operator==(const thread_t&, const other_t<I>&)
0546   {
0547     return false;
0548   }
0549 
0550   friend constexpr bool operator!=(const thread_t&, const other_t<I>&)
0551   {
0552     return true;
0553   }
0554 };
0555 
0556 #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
0557   && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0558 template <int I> template <typename E, typename T>
0559 const T thread_t<I>::static_query_v;
0560 #endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
0561        //   && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0562 
0563 template <int I = 0>
0564 struct new_thread_t
0565 {
0566 #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
0567   template <typename T>
0568   static constexpr bool is_applicable_property_v = is_executor<T>::value;
0569 #endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
0570 
0571   static constexpr bool is_requirable = true;
0572   static constexpr bool is_preferable = true;
0573   typedef mapping_t<I> polymorphic_query_result_type;
0574 
0575   constexpr new_thread_t()
0576   {
0577   }
0578 
0579   template <typename T>
0580   struct query_member :
0581     traits::query_member<
0582       typename mapping_t<I>::template proxy<T>::type, new_thread_t> {};
0583 
0584   template <typename T>
0585   struct query_static_constexpr_member :
0586     traits::query_static_constexpr_member<
0587       typename mapping_t<I>::template static_proxy<T>::type, new_thread_t> {};
0588 
0589 #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
0590   && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0591   template <typename T>
0592   static constexpr typename query_static_constexpr_member<T>::result_type
0593   static_query()
0594     noexcept(query_static_constexpr_member<T>::is_noexcept)
0595   {
0596     return query_static_constexpr_member<T>::value();
0597   }
0598 
0599   template <typename E, typename T = decltype(new_thread_t::static_query<E>())>
0600   static constexpr const T static_query_v = new_thread_t::static_query<E>();
0601 #endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
0602        //   && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0603 
0604   static constexpr mapping_t<I> value()
0605   {
0606     return new_thread_t();
0607   }
0608 
0609   friend constexpr bool operator==(const new_thread_t&, const new_thread_t&)
0610   {
0611     return true;
0612   }
0613 
0614   friend constexpr bool operator!=(const new_thread_t&, const new_thread_t&)
0615   {
0616     return false;
0617   }
0618 
0619   friend constexpr bool operator==(const new_thread_t&, const thread_t<I>&)
0620   {
0621     return false;
0622   }
0623 
0624   friend constexpr bool operator!=(const new_thread_t&, const thread_t<I>&)
0625   {
0626     return true;
0627   }
0628 
0629   friend constexpr bool operator==(const new_thread_t&, const other_t<I>&)
0630   {
0631     return false;
0632   }
0633 
0634   friend constexpr bool operator!=(const new_thread_t&, const other_t<I>&)
0635   {
0636     return true;
0637   }
0638 };
0639 
0640 #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
0641   && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0642 template <int I> template <typename E, typename T>
0643 const T new_thread_t<I>::static_query_v;
0644 #endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
0645        //   && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0646 
0647 template <int I>
0648 struct other_t
0649 {
0650 #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
0651   template <typename T>
0652   static constexpr bool is_applicable_property_v = is_executor<T>::value;
0653 #endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
0654 
0655   static constexpr bool is_requirable = true;
0656   static constexpr bool is_preferable = true;
0657   typedef mapping_t<I> polymorphic_query_result_type;
0658 
0659   constexpr other_t()
0660   {
0661   }
0662 
0663   template <typename T>
0664   struct query_member :
0665     traits::query_member<
0666       typename mapping_t<I>::template proxy<T>::type, other_t> {};
0667 
0668   template <typename T>
0669   struct query_static_constexpr_member :
0670     traits::query_static_constexpr_member<
0671       typename mapping_t<I>::template static_proxy<T>::type, other_t> {};
0672 
0673 #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
0674   && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0675   template <typename T>
0676   static constexpr
0677   typename query_static_constexpr_member<T>::result_type
0678   static_query()
0679     noexcept(query_static_constexpr_member<T>::is_noexcept)
0680   {
0681     return query_static_constexpr_member<T>::value();
0682   }
0683 
0684   template <typename E, typename T = decltype(other_t::static_query<E>())>
0685   static constexpr const T static_query_v = other_t::static_query<E>();
0686 #endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
0687        //   && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0688 
0689   static constexpr mapping_t<I> value()
0690   {
0691     return other_t();
0692   }
0693 
0694   friend constexpr bool operator==(const other_t&, const other_t&)
0695   {
0696     return true;
0697   }
0698 
0699   friend constexpr bool operator!=(const other_t&, const other_t&)
0700   {
0701     return false;
0702   }
0703 
0704   friend constexpr bool operator==(const other_t&, const thread_t<I>&)
0705   {
0706     return false;
0707   }
0708 
0709   friend constexpr bool operator!=(const other_t&, const thread_t<I>&)
0710   {
0711     return true;
0712   }
0713 
0714   friend constexpr bool operator==(const other_t&, const new_thread_t<I>&)
0715   {
0716     return false;
0717   }
0718 
0719   friend constexpr bool operator!=(const other_t&, const new_thread_t<I>&)
0720   {
0721     return true;
0722   }
0723 };
0724 
0725 #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
0726   && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0727 template <int I> template <typename E, typename T>
0728 const T other_t<I>::static_query_v;
0729 #endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
0730        //   && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0731 
0732 } // namespace mapping
0733 } // namespace detail
0734 
0735 typedef detail::mapping_t<> mapping_t;
0736 
0737 BOOST_ASIO_INLINE_VARIABLE constexpr mapping_t mapping;
0738 
0739 } // namespace execution
0740 
0741 #if !defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
0742 
0743 template <typename T>
0744 struct is_applicable_property<T, execution::mapping_t>
0745   : integral_constant<bool, execution::is_executor<T>::value>
0746 {
0747 };
0748 
0749 template <typename T>
0750 struct is_applicable_property<T, execution::mapping_t::thread_t>
0751   : integral_constant<bool, execution::is_executor<T>::value>
0752 {
0753 };
0754 
0755 template <typename T>
0756 struct is_applicable_property<T, execution::mapping_t::new_thread_t>
0757   : integral_constant<bool, execution::is_executor<T>::value>
0758 {
0759 };
0760 
0761 template <typename T>
0762 struct is_applicable_property<T, execution::mapping_t::other_t>
0763   : integral_constant<bool, execution::is_executor<T>::value>
0764 {
0765 };
0766 
0767 #endif // !defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
0768 
0769 namespace traits {
0770 
0771 #if !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
0772 
0773 template <typename T>
0774 struct query_free_default<T, execution::mapping_t,
0775   enable_if_t<
0776     can_query<T, execution::mapping_t::thread_t>::value
0777   >>
0778 {
0779   static constexpr bool is_valid = true;
0780   static constexpr bool is_noexcept =
0781     is_nothrow_query<T, execution::mapping_t::thread_t>::value;
0782 
0783   typedef execution::mapping_t result_type;
0784 };
0785 
0786 template <typename T>
0787 struct query_free_default<T, execution::mapping_t,
0788   enable_if_t<
0789     !can_query<T, execution::mapping_t::thread_t>::value
0790       && can_query<T, execution::mapping_t::new_thread_t>::value
0791   >>
0792 {
0793   static constexpr bool is_valid = true;
0794   static constexpr bool is_noexcept =
0795     is_nothrow_query<T, execution::mapping_t::new_thread_t>::value;
0796 
0797   typedef execution::mapping_t result_type;
0798 };
0799 
0800 template <typename T>
0801 struct query_free_default<T, execution::mapping_t,
0802   enable_if_t<
0803     !can_query<T, execution::mapping_t::thread_t>::value
0804       && !can_query<T, execution::mapping_t::new_thread_t>::value
0805       && can_query<T, execution::mapping_t::other_t>::value
0806   >>
0807 {
0808   static constexpr bool is_valid = true;
0809   static constexpr bool is_noexcept =
0810     is_nothrow_query<T, execution::mapping_t::other_t>::value;
0811 
0812   typedef execution::mapping_t result_type;
0813 };
0814 
0815 #endif // !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
0816 
0817 #if !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
0818   || !defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0819 
0820 template <typename T>
0821 struct static_query<T, execution::mapping_t,
0822   enable_if_t<
0823     execution::detail::mapping_t<0>::
0824       query_static_constexpr_member<T>::is_valid
0825   >>
0826 {
0827   static constexpr bool is_valid = true;
0828   static constexpr bool is_noexcept = true;
0829 
0830   typedef typename execution::detail::mapping_t<0>::
0831     query_static_constexpr_member<T>::result_type result_type;
0832 
0833   static constexpr result_type value()
0834   {
0835     return execution::detail::mapping_t<0>::
0836       query_static_constexpr_member<T>::value();
0837   }
0838 };
0839 
0840 template <typename T>
0841 struct static_query<T, execution::mapping_t,
0842   enable_if_t<
0843     !execution::detail::mapping_t<0>::
0844         query_static_constexpr_member<T>::is_valid
0845       && !execution::detail::mapping_t<0>::
0846         query_member<T>::is_valid
0847       && traits::static_query<T, execution::mapping_t::thread_t>::is_valid
0848   >>
0849 {
0850   static constexpr bool is_valid = true;
0851   static constexpr bool is_noexcept = true;
0852 
0853   typedef typename traits::static_query<T,
0854     execution::mapping_t::thread_t>::result_type result_type;
0855 
0856   static constexpr result_type value()
0857   {
0858     return traits::static_query<T, execution::mapping_t::thread_t>::value();
0859   }
0860 };
0861 
0862 template <typename T>
0863 struct static_query<T, execution::mapping_t,
0864   enable_if_t<
0865     !execution::detail::mapping_t<0>::
0866         query_static_constexpr_member<T>::is_valid
0867       && !execution::detail::mapping_t<0>::
0868         query_member<T>::is_valid
0869       && !traits::static_query<T, execution::mapping_t::thread_t>::is_valid
0870       && traits::static_query<T, execution::mapping_t::new_thread_t>::is_valid
0871   >>
0872 {
0873   static constexpr bool is_valid = true;
0874   static constexpr bool is_noexcept = true;
0875 
0876   typedef typename traits::static_query<T,
0877     execution::mapping_t::new_thread_t>::result_type result_type;
0878 
0879   static constexpr result_type value()
0880   {
0881     return traits::static_query<T, execution::mapping_t::new_thread_t>::value();
0882   }
0883 };
0884 
0885 template <typename T>
0886 struct static_query<T, execution::mapping_t,
0887   enable_if_t<
0888     !execution::detail::mapping_t<0>::
0889         query_static_constexpr_member<T>::is_valid
0890       && !execution::detail::mapping_t<0>::
0891         query_member<T>::is_valid
0892       && !traits::static_query<T, execution::mapping_t::thread_t>::is_valid
0893       && !traits::static_query<T, execution::mapping_t::new_thread_t>::is_valid
0894       && traits::static_query<T, execution::mapping_t::other_t>::is_valid
0895   >>
0896 {
0897   static constexpr bool is_valid = true;
0898   static constexpr bool is_noexcept = true;
0899 
0900   typedef typename traits::static_query<T,
0901     execution::mapping_t::other_t>::result_type result_type;
0902 
0903   static constexpr result_type value()
0904   {
0905     return traits::static_query<T, execution::mapping_t::other_t>::value();
0906   }
0907 };
0908 
0909 template <typename T>
0910 struct static_query<T, execution::mapping_t::thread_t,
0911   enable_if_t<
0912     execution::detail::mapping::thread_t<0>::
0913       query_static_constexpr_member<T>::is_valid
0914   >>
0915 {
0916   static constexpr bool is_valid = true;
0917   static constexpr bool is_noexcept = true;
0918 
0919   typedef typename execution::detail::mapping::thread_t<0>::
0920     query_static_constexpr_member<T>::result_type result_type;
0921 
0922   static constexpr result_type value()
0923   {
0924     return execution::detail::mapping::thread_t<0>::
0925       query_static_constexpr_member<T>::value();
0926   }
0927 };
0928 
0929 template <typename T>
0930 struct static_query<T, execution::mapping_t::thread_t,
0931   enable_if_t<
0932     !execution::detail::mapping::thread_t<0>::
0933         query_static_constexpr_member<T>::is_valid
0934       && !execution::detail::mapping::thread_t<0>::
0935         query_member<T>::is_valid
0936       && !traits::query_free<T, execution::mapping_t::thread_t>::is_valid
0937       && !can_query<T, execution::mapping_t::new_thread_t>::value
0938       && !can_query<T, execution::mapping_t::other_t>::value
0939   >>
0940 {
0941   static constexpr bool is_valid = true;
0942   static constexpr bool is_noexcept = true;
0943 
0944   typedef execution::mapping_t::thread_t result_type;
0945 
0946   static constexpr result_type value()
0947   {
0948     return result_type();
0949   }
0950 };
0951 
0952 template <typename T>
0953 struct static_query<T, execution::mapping_t::new_thread_t,
0954   enable_if_t<
0955     execution::detail::mapping::new_thread_t<0>::
0956       query_static_constexpr_member<T>::is_valid
0957   >>
0958 {
0959   static constexpr bool is_valid = true;
0960   static constexpr bool is_noexcept = true;
0961 
0962   typedef typename execution::detail::mapping::new_thread_t<0>::
0963     query_static_constexpr_member<T>::result_type result_type;
0964 
0965   static constexpr result_type value()
0966   {
0967     return execution::detail::mapping::new_thread_t<0>::
0968       query_static_constexpr_member<T>::value();
0969   }
0970 };
0971 
0972 template <typename T>
0973 struct static_query<T, execution::mapping_t::other_t,
0974   enable_if_t<
0975     execution::detail::mapping::other_t<0>::
0976       query_static_constexpr_member<T>::is_valid
0977   >>
0978 {
0979   static constexpr bool is_valid = true;
0980   static constexpr bool is_noexcept = true;
0981 
0982   typedef typename execution::detail::mapping::other_t<0>::
0983     query_static_constexpr_member<T>::result_type result_type;
0984 
0985   static constexpr result_type value()
0986   {
0987     return execution::detail::mapping::other_t<0>::
0988       query_static_constexpr_member<T>::value();
0989   }
0990 };
0991 
0992 #endif // !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
0993        //   || !defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0994 
0995 } // namespace traits
0996 
0997 #endif // defined(GENERATING_DOCUMENTATION)
0998 
0999 } // namespace asio
1000 } // namespace boost
1001 
1002 #include <boost/asio/detail/pop_options.hpp>
1003 
1004 #endif // BOOST_ASIO_EXECUTION_MAPPING_HPP