11 #ifndef ASIO_EXECUTION_PREFER_ONLY_HPP 12 #define ASIO_EXECUTION_PREFER_ONLY_HPP 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 18 #include "asio/detail/config.hpp" 19 #include "asio/detail/type_traits.hpp" 20 #include "asio/is_applicable_property.hpp" 21 #include "asio/prefer.hpp" 22 #include "asio/query.hpp" 23 #include "asio/traits/static_query.hpp" 25 #include "asio/detail/push_options.hpp" 29 #if defined(GENERATING_DOCUMENTATION) 35 template <
typename Property>
40 static constexpr
bool is_applicable_property_v =
41 is_applicable_property<T, Property>::value;
44 static constexpr
bool is_requirable =
false;
51 static constexpr
bool is_preferable = automatically_determined;
54 typedef typename Property::polymorphic_query_result_type
55 polymorphic_query_result_type;
60 #else // defined(GENERATING_DOCUMENTATION) 65 template <
typename InnerProperty,
typename =
void>
71 template <
typename InnerProperty>
80 template <
typename InnerProperty,
typename =
void>
85 template <
typename InnerProperty>
88 typename InnerProperty::polymorphic_query_result_type
91 typedef typename InnerProperty::polymorphic_query_result_type
92 polymorphic_query_result_type;
95 template <
typename InnerProperty,
typename =
void>
98 InnerProperty property;
106 #if defined(ASIO_HAS_DECLTYPE) \ 107 && defined(ASIO_HAS_WORKING_EXPRESSION_SFINAE) 109 template <
typename InnerProperty>
112 decltype(asio::declval<const InnerProperty>().value())
115 InnerProperty property;
122 ASIO_CONSTEXPR
auto value()
const 124 noexcept(asio::declval<const InnerProperty>().value())))
125 -> decltype(asio::declval<const InnerProperty>().value())
127 return property.value();
131 #else // defined(ASIO_HAS_DECLTYPE) 139 template <
typename T>
145 template <
typename T, T>
151 char (&prefer_only_value_memfn_helper(...))[2];
153 template <
typename T>
154 char prefer_only_value_memfn_helper(
159 template <
typename InnerProperty>
162 sizeof(prefer_only_value_memfn_helper<InnerProperty>(0)) != 1
163 && !is_same<
typename InnerProperty::polymorphic_query_result_type,
167 InnerProperty property;
174 ASIO_CONSTEXPR
typename InnerProperty::polymorphic_query_result_type
177 return property.value();
181 #endif // defined(ASIO_HAS_DECLTYPE) 186 template <
typename InnerProperty>
192 ASIO_STATIC_CONSTEXPR(
bool, is_requirable =
false);
199 #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 200 && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 201 template <
typename T>
202 static ASIO_CONSTEXPR
211 template <
typename E,
typename T = decltype(prefer_only::static_query<E>())>
212 static ASIO_CONSTEXPR
const T static_query_v
213 = prefer_only::static_query<E>();
214 #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 217 template <
typename Executor,
typename Property>
218 friend ASIO_CONSTEXPR
219 typename prefer_result<const Executor&, const InnerProperty&>::type
222 is_same<Property, InnerProperty>::value
225 #if !defined(ASIO_MSVC) \ 226 && !defined(__clang__) // Clang crashes if noexcept is used here. 229 #endif // !defined(ASIO_MSVC) 232 return asio::prefer(ex, p.property);
235 template <
typename Executor,
typename Property>
236 friend ASIO_CONSTEXPR
237 typename query_result<const Executor&, const InnerProperty&>::type
240 is_same<Property, InnerProperty>::value
243 #if !defined(ASIO_MSVC) \ 244 && !defined(__clang__) // Clang crashes if noexcept is used here. 247 #endif // !defined(ASIO_MSVC) 250 return asio::query(ex, p.property);
254 #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 255 && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 256 template <
typename InnerProperty>
template <
typename E,
typename T>
258 #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 263 template <
typename T,
typename InnerProperty>
271 #if !defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 272 || !defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 274 template <
typename T,
typename InnerProperty>
280 #endif // !defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 283 #if !defined(ASIO_HAS_DEDUCED_PREFER_FREE_TRAIT) 285 template <
typename T,
typename InnerProperty>
288 can_prefer<const T&, const InnerProperty&>::value
291 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
292 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
296 const InnerProperty&>::type result_type;
299 #endif // !defined(ASIO_HAS_DEDUCED_PREFER_FREE_TRAIT) 301 #if !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) 303 template <
typename T,
typename InnerProperty>
306 can_query<const T&, const InnerProperty&>::value
309 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
310 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
314 const InnerProperty&>::type result_type;
317 #endif // !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) 321 #endif // defined(GENERATING_DOCUMENTATION) 325 #include "asio/detail/pop_options.hpp" 327 #endif // ASIO_EXECUTION_PREFER_ONLY_HPP Definition: prefer.hpp:574
Definition: prefer_only.hpp:187
Definition: type_traits.hpp:135
Definition: prefer_only.hpp:66
Definition: query.hpp:269
Definition: prefer_only.hpp:146
Definition: static_query.hpp:42
Definition: query.hpp:284
Definition: prefer_only.hpp:96
Definition: prefer_only.hpp:134
Definition: type_traits.hpp:97
Definition: query.hpp:253
Definition: prefer_only.hpp:81
Definition: prefer_only.hpp:140
Definition: query_free.hpp:38
Definition: any_executor.hpp:256
Definition: prefer.hpp:623
Definition: handler_work.hpp:37
Definition: prefer.hpp:522
Definition: is_applicable_property.hpp:46
Definition: any_io_executor.hpp:28
Definition: prefer_free.hpp:35