outstanding_work.hpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  1. //
  2. // execution/outstanding_work.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef ASIO_EXECUTION_OUTSTANDING_WORK_HPP
  11. #define ASIO_EXECUTION_OUTSTANDING_WORK_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include "asio/detail/config.hpp"
  16. #include "asio/detail/type_traits.hpp"
  17. #include "asio/execution/executor.hpp"
  18. #include "asio/is_applicable_property.hpp"
  19. #include "asio/query.hpp"
  20. #include "asio/traits/query_free.hpp"
  21. #include "asio/traits/query_member.hpp"
  22. #include "asio/traits/query_static_constexpr_member.hpp"
  23. #include "asio/traits/static_query.hpp"
  24. #include "asio/traits/static_require.hpp"
  25. #include "asio/detail/push_options.hpp"
  26. namespace asio {
  27. #if defined(GENERATING_DOCUMENTATION)
  28. namespace execution {
  29. /// A property to describe whether task submission is likely in the future.
  30. struct outstanding_work_t
  31. {
  32. /// The outstanding_work_t property applies to executors.
  33. template <typename T>
  34. static constexpr bool is_applicable_property_v = is_executor_v<T>;
  35. /// The top-level outstanding_work_t property cannot be required.
  36. static constexpr bool is_requirable = false;
  37. /// The top-level outstanding_work_t property cannot be preferred.
  38. static constexpr bool is_preferable = false;
  39. /// The type returned by queries against an @c any_executor.
  40. typedef outstanding_work_t polymorphic_query_result_type;
  41. /// A sub-property that indicates that the executor does not represent likely
  42. /// future submission of a function object.
  43. struct untracked_t
  44. {
  45. /// The outstanding_work_t::untracked_t property applies to executors.
  46. template <typename T>
  47. static constexpr bool is_applicable_property_v = is_executor_v<T>;
  48. /// The outstanding_work_t::untracked_t property can be required.
  49. static constexpr bool is_requirable = true;
  50. /// The outstanding_work_t::untracked_t property can be preferred.
  51. static constexpr bool is_preferable = true;
  52. /// The type returned by queries against an @c any_executor.
  53. typedef outstanding_work_t polymorphic_query_result_type;
  54. /// Default constructor.
  55. constexpr untracked_t();
  56. /// Get the value associated with a property object.
  57. /**
  58. * @returns untracked_t();
  59. */
  60. static constexpr outstanding_work_t value();
  61. };
  62. /// A sub-property that indicates that the executor represents likely
  63. /// future submission of a function object.
  64. struct tracked_t
  65. {
  66. /// The outstanding_work_t::untracked_t property applies to executors.
  67. template <typename T>
  68. static constexpr bool is_applicable_property_v = is_executor_v<T>;
  69. /// The outstanding_work_t::tracked_t property can be required.
  70. static constexpr bool is_requirable = true;
  71. /// The outstanding_work_t::tracked_t property can be preferred.
  72. static constexpr bool is_preferable = true;
  73. /// The type returned by queries against an @c any_executor.
  74. typedef outstanding_work_t polymorphic_query_result_type;
  75. /// Default constructor.
  76. constexpr tracked_t();
  77. /// Get the value associated with a property object.
  78. /**
  79. * @returns tracked_t();
  80. */
  81. static constexpr outstanding_work_t value();
  82. };
  83. /// A special value used for accessing the outstanding_work_t::untracked_t
  84. /// property.
  85. static constexpr untracked_t untracked;
  86. /// A special value used for accessing the outstanding_work_t::tracked_t
  87. /// property.
  88. static constexpr tracked_t tracked;
  89. /// Default constructor.
  90. constexpr outstanding_work_t();
  91. /// Construct from a sub-property value.
  92. constexpr outstanding_work_t(untracked_t);
  93. /// Construct from a sub-property value.
  94. constexpr outstanding_work_t(tracked_t);
  95. /// Compare property values for equality.
  96. friend constexpr bool operator==(
  97. const outstanding_work_t& a, const outstanding_work_t& b) noexcept;
  98. /// Compare property values for inequality.
  99. friend constexpr bool operator!=(
  100. const outstanding_work_t& a, const outstanding_work_t& b) noexcept;
  101. };
  102. /// A special value used for accessing the outstanding_work_t property.
  103. constexpr outstanding_work_t outstanding_work;
  104. } // namespace execution
  105. #else // defined(GENERATING_DOCUMENTATION)
  106. namespace execution {
  107. namespace detail {
  108. namespace outstanding_work {
  109. template <int I> struct untracked_t;
  110. template <int I> struct tracked_t;
  111. } // namespace outstanding_work
  112. template <int I = 0>
  113. struct outstanding_work_t
  114. {
  115. #if defined(ASIO_HAS_VARIABLE_TEMPLATES)
  116. template <typename T>
  117. static constexpr bool is_applicable_property_v = is_executor<T>::value;
  118. #endif // defined(ASIO_HAS_VARIABLE_TEMPLATES)
  119. static constexpr bool is_requirable = false;
  120. static constexpr bool is_preferable = false;
  121. typedef outstanding_work_t polymorphic_query_result_type;
  122. typedef detail::outstanding_work::untracked_t<I> untracked_t;
  123. typedef detail::outstanding_work::tracked_t<I> tracked_t;
  124. constexpr outstanding_work_t()
  125. : value_(-1)
  126. {
  127. }
  128. constexpr outstanding_work_t(untracked_t)
  129. : value_(0)
  130. {
  131. }
  132. constexpr outstanding_work_t(tracked_t)
  133. : value_(1)
  134. {
  135. }
  136. template <typename T>
  137. struct proxy
  138. {
  139. #if defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
  140. struct type
  141. {
  142. template <typename P>
  143. auto query(P&& p) const
  144. noexcept(
  145. noexcept(
  146. declval<conditional_t<true, T, P>>().query(static_cast<P&&>(p))
  147. )
  148. )
  149. -> decltype(
  150. declval<conditional_t<true, T, P>>().query(static_cast<P&&>(p))
  151. );
  152. };
  153. #else // defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
  154. typedef T type;
  155. #endif // defined(ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
  156. };
  157. template <typename T>
  158. struct static_proxy
  159. {
  160. #if defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
  161. struct type
  162. {
  163. template <typename P>
  164. static constexpr auto query(P&& p)
  165. noexcept(
  166. noexcept(
  167. conditional_t<true, T, P>::query(static_cast<P&&>(p))
  168. )
  169. )
  170. -> decltype(
  171. conditional_t<true, T, P>::query(static_cast<P&&>(p))
  172. )
  173. {
  174. return T::query(static_cast<P&&>(p));
  175. }
  176. };
  177. #else // defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
  178. typedef T type;
  179. #endif // defined(ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
  180. };
  181. template <typename T>
  182. struct query_member :
  183. traits::query_member<typename proxy<T>::type, outstanding_work_t> {};
  184. template <typename T>
  185. struct query_static_constexpr_member :
  186. traits::query_static_constexpr_member<
  187. typename static_proxy<T>::type, outstanding_work_t> {};
  188. #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
  189. && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  190. template <typename T>
  191. static constexpr
  192. typename query_static_constexpr_member<T>::result_type
  193. static_query()
  194. noexcept(query_static_constexpr_member<T>::is_noexcept)
  195. {
  196. return query_static_constexpr_member<T>::value();
  197. }
  198. template <typename T>
  199. static constexpr
  200. typename traits::static_query<T, untracked_t>::result_type
  201. static_query(
  202. enable_if_t<
  203. !query_static_constexpr_member<T>::is_valid
  204. >* = 0,
  205. enable_if_t<
  206. !query_member<T>::is_valid
  207. >* = 0,
  208. enable_if_t<
  209. traits::static_query<T, untracked_t>::is_valid
  210. >* = 0) noexcept
  211. {
  212. return traits::static_query<T, untracked_t>::value();
  213. }
  214. template <typename T>
  215. static constexpr
  216. typename traits::static_query<T, tracked_t>::result_type
  217. static_query(
  218. enable_if_t<
  219. !query_static_constexpr_member<T>::is_valid
  220. >* = 0,
  221. enable_if_t<
  222. !query_member<T>::is_valid
  223. >* = 0,
  224. enable_if_t<
  225. !traits::static_query<T, untracked_t>::is_valid
  226. >* = 0,
  227. enable_if_t<
  228. traits::static_query<T, tracked_t>::is_valid
  229. >* = 0) noexcept
  230. {
  231. return traits::static_query<T, tracked_t>::value();
  232. }
  233. template <typename E,
  234. typename T = decltype(outstanding_work_t::static_query<E>())>
  235. static constexpr const T static_query_v
  236. = outstanding_work_t::static_query<E>();
  237. #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
  238. // && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  239. friend constexpr bool operator==(
  240. const outstanding_work_t& a, const outstanding_work_t& b)
  241. {
  242. return a.value_ == b.value_;
  243. }
  244. friend constexpr bool operator!=(
  245. const outstanding_work_t& a, const outstanding_work_t& b)
  246. {
  247. return a.value_ != b.value_;
  248. }
  249. struct convertible_from_outstanding_work_t
  250. {
  251. constexpr convertible_from_outstanding_work_t(outstanding_work_t)
  252. {
  253. }
  254. };
  255. template <typename Executor>
  256. friend constexpr outstanding_work_t query(
  257. const Executor& ex, convertible_from_outstanding_work_t,
  258. enable_if_t<
  259. can_query<const Executor&, untracked_t>::value
  260. >* = 0)
  261. #if !defined(__clang__) // Clang crashes if noexcept is used here.
  262. #if defined(ASIO_MSVC) // Visual C++ wants the type to be qualified.
  263. noexcept(is_nothrow_query<const Executor&,
  264. outstanding_work_t<>::untracked_t>::value)
  265. #else // defined(ASIO_MSVC)
  266. noexcept(is_nothrow_query<const Executor&, untracked_t>::value)
  267. #endif // defined(ASIO_MSVC)
  268. #endif // !defined(__clang__)
  269. {
  270. return asio::query(ex, untracked_t());
  271. }
  272. template <typename Executor>
  273. friend constexpr outstanding_work_t query(
  274. const Executor& ex, convertible_from_outstanding_work_t,
  275. enable_if_t<
  276. !can_query<const Executor&, untracked_t>::value
  277. >* = 0,
  278. enable_if_t<
  279. can_query<const Executor&, tracked_t>::value
  280. >* = 0)
  281. #if !defined(__clang__) // Clang crashes if noexcept is used here.
  282. #if defined(ASIO_MSVC) // Visual C++ wants the type to be qualified.
  283. noexcept(is_nothrow_query<const Executor&,
  284. outstanding_work_t<>::tracked_t>::value)
  285. #else // defined(ASIO_MSVC)
  286. noexcept(is_nothrow_query<const Executor&, tracked_t>::value)
  287. #endif // defined(ASIO_MSVC)
  288. #endif // !defined(__clang__)
  289. {
  290. return asio::query(ex, tracked_t());
  291. }
  292. ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(untracked_t, untracked);
  293. ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(tracked_t, tracked);
  294. private:
  295. int value_;
  296. };
  297. #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
  298. && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  299. template <int I> template <typename E, typename T>
  300. const T outstanding_work_t<I>::static_query_v;
  301. #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
  302. // && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  303. template <int I>
  304. const typename outstanding_work_t<I>::untracked_t
  305. outstanding_work_t<I>::untracked;
  306. template <int I>
  307. const typename outstanding_work_t<I>::tracked_t
  308. outstanding_work_t<I>::tracked;
  309. namespace outstanding_work {
  310. template <int I = 0>
  311. struct untracked_t
  312. {
  313. #if defined(ASIO_HAS_VARIABLE_TEMPLATES)
  314. template <typename T>
  315. static constexpr bool is_applicable_property_v = is_executor<T>::value;
  316. #endif // defined(ASIO_HAS_VARIABLE_TEMPLATES)
  317. static constexpr bool is_requirable = true;
  318. static constexpr bool is_preferable = true;
  319. typedef outstanding_work_t<I> polymorphic_query_result_type;
  320. constexpr untracked_t()
  321. {
  322. }
  323. template <typename T>
  324. struct query_member :
  325. traits::query_member<
  326. typename outstanding_work_t<I>::template proxy<T>::type, untracked_t> {};
  327. template <typename T>
  328. struct query_static_constexpr_member :
  329. traits::query_static_constexpr_member<
  330. typename outstanding_work_t<I>::template static_proxy<T>::type,
  331. untracked_t> {};
  332. #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
  333. && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  334. template <typename T>
  335. static constexpr
  336. typename query_static_constexpr_member<T>::result_type
  337. static_query()
  338. noexcept(query_static_constexpr_member<T>::is_noexcept)
  339. {
  340. return query_static_constexpr_member<T>::value();
  341. }
  342. template <typename T>
  343. static constexpr untracked_t static_query(
  344. enable_if_t<
  345. !query_static_constexpr_member<T>::is_valid
  346. >* = 0,
  347. enable_if_t<
  348. !query_member<T>::is_valid
  349. >* = 0,
  350. enable_if_t<
  351. !traits::query_free<T, untracked_t>::is_valid
  352. >* = 0,
  353. enable_if_t<
  354. !can_query<T, tracked_t<I>>::value
  355. >* = 0) noexcept
  356. {
  357. return untracked_t();
  358. }
  359. template <typename E, typename T = decltype(untracked_t::static_query<E>())>
  360. static constexpr const T static_query_v = untracked_t::static_query<E>();
  361. #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
  362. // && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  363. static constexpr outstanding_work_t<I> value()
  364. {
  365. return untracked_t();
  366. }
  367. friend constexpr bool operator==(const untracked_t&, const untracked_t&)
  368. {
  369. return true;
  370. }
  371. friend constexpr bool operator!=(const untracked_t&, const untracked_t&)
  372. {
  373. return false;
  374. }
  375. friend constexpr bool operator==(const untracked_t&, const tracked_t<I>&)
  376. {
  377. return false;
  378. }
  379. friend constexpr bool operator!=(const untracked_t&, const tracked_t<I>&)
  380. {
  381. return true;
  382. }
  383. };
  384. #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
  385. && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  386. template <int I> template <typename E, typename T>
  387. const T untracked_t<I>::static_query_v;
  388. #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
  389. // && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  390. template <int I = 0>
  391. struct tracked_t
  392. {
  393. #if defined(ASIO_HAS_VARIABLE_TEMPLATES)
  394. template <typename T>
  395. static constexpr bool is_applicable_property_v = is_executor<T>::value;
  396. #endif // defined(ASIO_HAS_VARIABLE_TEMPLATES)
  397. static constexpr bool is_requirable = true;
  398. static constexpr bool is_preferable = true;
  399. typedef outstanding_work_t<I> polymorphic_query_result_type;
  400. constexpr tracked_t()
  401. {
  402. }
  403. template <typename T>
  404. struct query_member :
  405. traits::query_member<
  406. typename outstanding_work_t<I>::template proxy<T>::type, tracked_t> {};
  407. template <typename T>
  408. struct query_static_constexpr_member :
  409. traits::query_static_constexpr_member<
  410. typename outstanding_work_t<I>::template static_proxy<T>::type,
  411. tracked_t> {};
  412. #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
  413. && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  414. template <typename T>
  415. static constexpr
  416. typename query_static_constexpr_member<T>::result_type
  417. static_query()
  418. noexcept(query_static_constexpr_member<T>::is_noexcept)
  419. {
  420. return query_static_constexpr_member<T>::value();
  421. }
  422. template <typename E, typename T = decltype(tracked_t::static_query<E>())>
  423. static constexpr const T static_query_v = tracked_t::static_query<E>();
  424. #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
  425. // && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  426. static constexpr outstanding_work_t<I> value()
  427. {
  428. return tracked_t();
  429. }
  430. friend constexpr bool operator==(const tracked_t&, const tracked_t&)
  431. {
  432. return true;
  433. }
  434. friend constexpr bool operator!=(const tracked_t&, const tracked_t&)
  435. {
  436. return false;
  437. }
  438. friend constexpr bool operator==(const tracked_t&, const untracked_t<I>&)
  439. {
  440. return false;
  441. }
  442. friend constexpr bool operator!=(const tracked_t&, const untracked_t<I>&)
  443. {
  444. return true;
  445. }
  446. };
  447. #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
  448. && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  449. template <int I> template <typename E, typename T>
  450. const T tracked_t<I>::static_query_v;
  451. #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
  452. // && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  453. } // namespace outstanding_work
  454. } // namespace detail
  455. typedef detail::outstanding_work_t<> outstanding_work_t;
  456. constexpr outstanding_work_t outstanding_work;
  457. } // namespace execution
  458. #if !defined(ASIO_HAS_VARIABLE_TEMPLATES)
  459. template <typename T>
  460. struct is_applicable_property<T, execution::outstanding_work_t>
  461. : integral_constant<bool, execution::is_executor<T>::value>
  462. {
  463. };
  464. template <typename T>
  465. struct is_applicable_property<T, execution::outstanding_work_t::untracked_t>
  466. : integral_constant<bool, execution::is_executor<T>::value>
  467. {
  468. };
  469. template <typename T>
  470. struct is_applicable_property<T, execution::outstanding_work_t::tracked_t>
  471. : integral_constant<bool, execution::is_executor<T>::value>
  472. {
  473. };
  474. #endif // !defined(ASIO_HAS_VARIABLE_TEMPLATES)
  475. namespace traits {
  476. #if !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
  477. template <typename T>
  478. struct query_free_default<T, execution::outstanding_work_t,
  479. enable_if_t<
  480. can_query<T, execution::outstanding_work_t::untracked_t>::value
  481. >>
  482. {
  483. static constexpr bool is_valid = true;
  484. static constexpr bool is_noexcept =
  485. is_nothrow_query<T, execution::outstanding_work_t::untracked_t>::value;
  486. typedef execution::outstanding_work_t result_type;
  487. };
  488. template <typename T>
  489. struct query_free_default<T, execution::outstanding_work_t,
  490. enable_if_t<
  491. !can_query<T, execution::outstanding_work_t::untracked_t>::value
  492. && can_query<T, execution::outstanding_work_t::tracked_t>::value
  493. >>
  494. {
  495. static constexpr bool is_valid = true;
  496. static constexpr bool is_noexcept =
  497. is_nothrow_query<T, execution::outstanding_work_t::tracked_t>::value;
  498. typedef execution::outstanding_work_t result_type;
  499. };
  500. #endif // !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
  501. #if !defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
  502. || !defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  503. template <typename T>
  504. struct static_query<T, execution::outstanding_work_t,
  505. enable_if_t<
  506. execution::detail::outstanding_work_t<0>::
  507. query_static_constexpr_member<T>::is_valid
  508. >>
  509. {
  510. static constexpr bool is_valid = true;
  511. static constexpr bool is_noexcept = true;
  512. typedef typename execution::detail::outstanding_work_t<0>::
  513. query_static_constexpr_member<T>::result_type result_type;
  514. static constexpr result_type value()
  515. {
  516. return execution::detail::outstanding_work_t<0>::
  517. query_static_constexpr_member<T>::value();
  518. }
  519. };
  520. template <typename T>
  521. struct static_query<T, execution::outstanding_work_t,
  522. enable_if_t<
  523. !execution::detail::outstanding_work_t<0>::
  524. query_static_constexpr_member<T>::is_valid
  525. && !execution::detail::outstanding_work_t<0>::
  526. query_member<T>::is_valid
  527. && traits::static_query<T,
  528. execution::outstanding_work_t::untracked_t>::is_valid
  529. >>
  530. {
  531. static constexpr bool is_valid = true;
  532. static constexpr bool is_noexcept = true;
  533. typedef typename traits::static_query<T,
  534. execution::outstanding_work_t::untracked_t>::result_type result_type;
  535. static constexpr result_type value()
  536. {
  537. return traits::static_query<T,
  538. execution::outstanding_work_t::untracked_t>::value();
  539. }
  540. };
  541. template <typename T>
  542. struct static_query<T, execution::outstanding_work_t,
  543. enable_if_t<
  544. !execution::detail::outstanding_work_t<0>::
  545. query_static_constexpr_member<T>::is_valid
  546. && !execution::detail::outstanding_work_t<0>::
  547. query_member<T>::is_valid
  548. && !traits::static_query<T,
  549. execution::outstanding_work_t::untracked_t>::is_valid
  550. && traits::static_query<T,
  551. execution::outstanding_work_t::tracked_t>::is_valid
  552. >>
  553. {
  554. static constexpr bool is_valid = true;
  555. static constexpr bool is_noexcept = true;
  556. typedef typename traits::static_query<T,
  557. execution::outstanding_work_t::tracked_t>::result_type result_type;
  558. static constexpr result_type value()
  559. {
  560. return traits::static_query<T,
  561. execution::outstanding_work_t::tracked_t>::value();
  562. }
  563. };
  564. template <typename T>
  565. struct static_query<T, execution::outstanding_work_t::untracked_t,
  566. enable_if_t<
  567. execution::detail::outstanding_work::untracked_t<0>::
  568. query_static_constexpr_member<T>::is_valid
  569. >>
  570. {
  571. static constexpr bool is_valid = true;
  572. static constexpr bool is_noexcept = true;
  573. typedef typename execution::detail::outstanding_work::untracked_t<0>::
  574. query_static_constexpr_member<T>::result_type result_type;
  575. static constexpr result_type value()
  576. {
  577. return execution::detail::outstanding_work::untracked_t<0>::
  578. query_static_constexpr_member<T>::value();
  579. }
  580. };
  581. template <typename T>
  582. struct static_query<T, execution::outstanding_work_t::untracked_t,
  583. enable_if_t<
  584. !execution::detail::outstanding_work::untracked_t<0>::
  585. query_static_constexpr_member<T>::is_valid
  586. && !execution::detail::outstanding_work::untracked_t<0>::
  587. query_member<T>::is_valid
  588. && !traits::query_free<T,
  589. execution::outstanding_work_t::untracked_t>::is_valid
  590. && !can_query<T, execution::outstanding_work_t::tracked_t>::value
  591. >>
  592. {
  593. static constexpr bool is_valid = true;
  594. static constexpr bool is_noexcept = true;
  595. typedef execution::outstanding_work_t::untracked_t result_type;
  596. static constexpr result_type value()
  597. {
  598. return result_type();
  599. }
  600. };
  601. template <typename T>
  602. struct static_query<T, execution::outstanding_work_t::tracked_t,
  603. enable_if_t<
  604. execution::detail::outstanding_work::tracked_t<0>::
  605. query_static_constexpr_member<T>::is_valid
  606. >>
  607. {
  608. static constexpr bool is_valid = true;
  609. static constexpr bool is_noexcept = true;
  610. typedef typename execution::detail::outstanding_work::tracked_t<0>::
  611. query_static_constexpr_member<T>::result_type result_type;
  612. static constexpr result_type value()
  613. {
  614. return execution::detail::outstanding_work::tracked_t<0>::
  615. query_static_constexpr_member<T>::value();
  616. }
  617. };
  618. #endif // !defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
  619. // || !defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  620. } // namespace traits
  621. #endif // defined(GENERATING_DOCUMENTATION)
  622. } // namespace asio
  623. #include "asio/detail/pop_options.hpp"
  624. #endif // ASIO_EXECUTION_OUTSTANDING_WORK_HPP