File indexing completed on 2025-12-16 09:43:17
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_EXECUTION_CONTEXT2_HPP
0012 #define BOOST_ASIO_EXECUTION_CONTEXT2_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
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/traits/query_static_constexpr_member.hpp>
0023 #include <boost/asio/traits/static_query.hpp>
0024
0025 #if defined(BOOST_ASIO_HAS_STD_ANY)
0026 # include <any>
0027 #endif
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
0039
0040 struct context_t
0041 {
0042
0043 template <typename T>
0044 static constexpr bool is_applicable_property_v = is_executor_v<T>;
0045
0046
0047 static constexpr bool is_requirable = false;
0048
0049
0050 static constexpr bool is_preferable = false;
0051
0052
0053 typedef std::any polymorphic_query_result_type;
0054 };
0055
0056
0057 constexpr context_t context;
0058
0059 }
0060
0061 #else
0062
0063 namespace execution {
0064 namespace detail {
0065
0066 template <int I = 0>
0067 struct context_t
0068 {
0069 #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
0070 template <typename T>
0071 static constexpr bool is_applicable_property_v = is_executor<T>::value;
0072 #endif
0073
0074 static constexpr bool is_requirable = false;
0075 static constexpr bool is_preferable = false;
0076
0077 #if defined(BOOST_ASIO_HAS_STD_ANY)
0078 typedef std::any polymorphic_query_result_type;
0079 #endif
0080
0081 constexpr context_t()
0082 {
0083 }
0084
0085 template <typename T>
0086 struct static_proxy
0087 {
0088 #if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
0089 struct type
0090 {
0091 template <typename P>
0092 static constexpr auto query(P&& p)
0093 noexcept(
0094 noexcept(
0095 conditional_t<true, T, P>::query(static_cast<P&&>(p))
0096 )
0097 )
0098 -> decltype(
0099 conditional_t<true, T, P>::query(static_cast<P&&>(p))
0100 )
0101 {
0102 return T::query(static_cast<P&&>(p));
0103 }
0104 };
0105 #else
0106 typedef T type;
0107 #endif
0108 };
0109
0110 template <typename T>
0111 struct query_static_constexpr_member :
0112 traits::query_static_constexpr_member<
0113 typename static_proxy<T>::type, context_t> {};
0114
0115 #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
0116 && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0117 template <typename T>
0118 static constexpr typename query_static_constexpr_member<T>::result_type
0119 static_query()
0120 noexcept(query_static_constexpr_member<T>::is_noexcept)
0121 {
0122 return query_static_constexpr_member<T>::value();
0123 }
0124
0125 template <typename E, typename T = decltype(context_t::static_query<E>())>
0126 static constexpr const T static_query_v = context_t::static_query<E>();
0127 #endif
0128
0129 };
0130
0131 #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
0132 && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0133 template <int I> template <typename E, typename T>
0134 const T context_t<I>::static_query_v;
0135 #endif
0136
0137
0138 }
0139
0140 typedef detail::context_t<> context_t;
0141
0142 BOOST_ASIO_INLINE_VARIABLE constexpr context_t context;
0143
0144 }
0145
0146 #if !defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
0147
0148 template <typename T>
0149 struct is_applicable_property<T, execution::context_t>
0150 : integral_constant<bool, execution::is_executor<T>::value>
0151 {
0152 };
0153
0154 #endif
0155
0156 namespace traits {
0157
0158 #if !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
0159 || !defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0160
0161 template <typename T>
0162 struct static_query<T, execution::context_t,
0163 enable_if_t<
0164 execution::detail::context_t<0>::
0165 query_static_constexpr_member<T>::is_valid
0166 >>
0167 {
0168 static constexpr bool is_valid = true;
0169 static constexpr bool is_noexcept = true;
0170
0171 typedef typename execution::detail::context_t<0>::
0172 query_static_constexpr_member<T>::result_type result_type;
0173
0174 static constexpr result_type value()
0175 {
0176 return execution::detail::context_t<0>::
0177 query_static_constexpr_member<T>::value();
0178 }
0179 };
0180
0181 #endif
0182
0183
0184 }
0185
0186 #endif
0187
0188 }
0189 }
0190
0191 #include <boost/asio/detail/pop_options.hpp>
0192
0193 #endif