outstanding_work.hpp 22 KB

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