File indexing completed on 2024-11-16 09:05:21
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_EXECUTION_CONTEXT_AS_HPP
0012 #define BOOST_ASIO_EXECUTION_CONTEXT_AS_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/context.hpp>
0021 #include <boost/asio/execution/executor.hpp>
0022 #include <boost/asio/is_applicable_property.hpp>
0023 #include <boost/asio/query.hpp>
0024 #include <boost/asio/traits/query_static_constexpr_member.hpp>
0025 #include <boost/asio/traits/static_query.hpp>
0026
0027 #include <boost/asio/detail/push_options.hpp>
0028
0029 namespace boost {
0030 namespace asio {
0031
0032 #if defined(GENERATING_DOCUMENTATION)
0033
0034 namespace execution {
0035
0036
0037
0038 template <typename U>
0039 struct context_as_t
0040 {
0041
0042 template <typename T>
0043 static constexpr bool is_applicable_property_v = is_executor_v<T>;
0044
0045
0046 static constexpr bool is_requirable = false;
0047
0048
0049 static constexpr bool is_preferable = false;
0050
0051
0052 typedef T polymorphic_query_result_type;
0053 };
0054
0055
0056 template <typename U>
0057 constexpr context_as_t context_as;
0058
0059 }
0060
0061 #else
0062
0063 namespace execution {
0064
0065 template <typename T>
0066 struct context_as_t
0067 {
0068 #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
0069 template <typename U>
0070 static constexpr bool is_applicable_property_v = is_executor<U>::value;
0071 #endif
0072
0073 static constexpr bool is_requirable = false;
0074 static constexpr bool is_preferable = false;
0075
0076 typedef T polymorphic_query_result_type;
0077
0078 constexpr context_as_t()
0079 {
0080 }
0081
0082 constexpr context_as_t(context_t)
0083 {
0084 }
0085
0086 #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
0087 && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0088 template <typename E>
0089 static constexpr
0090 typename context_t::query_static_constexpr_member<E>::result_type
0091 static_query()
0092 noexcept(context_t::query_static_constexpr_member<E>::is_noexcept)
0093 {
0094 return context_t::query_static_constexpr_member<E>::value();
0095 }
0096
0097 template <typename E, typename U = decltype(context_as_t::static_query<E>())>
0098 static constexpr const U static_query_v
0099 = context_as_t::static_query<E>();
0100 #endif
0101
0102
0103 template <typename Executor, typename U>
0104 friend constexpr U query(
0105 const Executor& ex, const context_as_t<U>&,
0106 enable_if_t<
0107 is_same<T, U>::value
0108 >* = 0,
0109 enable_if_t<
0110 can_query<const Executor&, const context_t&>::value
0111 >* = 0)
0112 #if !defined(__clang__)
0113 #if defined(BOOST_ASIO_MSVC)
0114 noexcept(is_nothrow_query<const Executor&, const context_t&>::value)
0115 #else
0116 noexcept(is_nothrow_query<const Executor&, const context_t&>::value)
0117 #endif
0118 #endif
0119 {
0120 return boost::asio::query(ex, context);
0121 }
0122 };
0123
0124 #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
0125 && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0126 template <typename T> template <typename E, typename U>
0127 const U context_as_t<T>::static_query_v;
0128 #endif
0129
0130
0131 #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES) \
0132 || defined(GENERATING_DOCUMENTATION)
0133 template <typename T>
0134 constexpr context_as_t<T> context_as{};
0135 #endif
0136
0137
0138 }
0139
0140 #if !defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
0141
0142 template <typename T, typename U>
0143 struct is_applicable_property<T, execution::context_as_t<U>>
0144 : integral_constant<bool, execution::is_executor<T>::value>
0145 {
0146 };
0147
0148 #endif
0149
0150 namespace traits {
0151
0152 #if !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
0153 || !defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
0154
0155 template <typename T, typename U>
0156 struct static_query<T, execution::context_as_t<U>,
0157 enable_if_t<
0158 static_query<T, execution::context_t>::is_valid
0159 >> : static_query<T, execution::context_t>
0160 {
0161 };
0162
0163 #endif
0164
0165
0166 #if !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
0167
0168 template <typename T, typename U>
0169 struct query_free<T, execution::context_as_t<U>,
0170 enable_if_t<
0171 can_query<const T&, const execution::context_t&>::value
0172 >>
0173 {
0174 static constexpr bool is_valid = true;
0175 static constexpr bool is_noexcept =
0176 is_nothrow_query<const T&, const execution::context_t&>::value;
0177
0178 typedef U result_type;
0179 };
0180
0181 #endif
0182
0183 }
0184
0185 #endif
0186
0187 }
0188 }
0189
0190 #include <boost/asio/detail/pop_options.hpp>
0191
0192 #endif