blocking.hpp 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362
  1. //
  2. // execution/blocking.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_BLOCKING_HPP
  11. #define BOOST_ASIO_EXECUTION_BLOCKING_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/prefer.hpp>
  20. #include <boost/asio/query.hpp>
  21. #include <boost/asio/require.hpp>
  22. #include <boost/asio/traits/execute_member.hpp>
  23. #include <boost/asio/traits/query_free.hpp>
  24. #include <boost/asio/traits/query_member.hpp>
  25. #include <boost/asio/traits/query_static_constexpr_member.hpp>
  26. #include <boost/asio/traits/static_query.hpp>
  27. #include <boost/asio/traits/static_require.hpp>
  28. #include <boost/asio/detail/push_options.hpp>
  29. namespace boost {
  30. namespace asio {
  31. #if defined(GENERATING_DOCUMENTATION)
  32. namespace execution {
  33. /// A property to describe what guarantees an executor makes about the blocking
  34. /// behaviour of their execution functions.
  35. struct blocking_t
  36. {
  37. /// The blocking_t property applies to executors.
  38. template <typename T>
  39. static constexpr bool is_applicable_property_v = is_executor_v<T>;
  40. /// The top-level blocking_t property cannot be required.
  41. static constexpr bool is_requirable = false;
  42. /// The top-level blocking_t property cannot be preferred.
  43. static constexpr bool is_preferable = false;
  44. /// The type returned by queries against an @c any_executor.
  45. typedef blocking_t polymorphic_query_result_type;
  46. /// A sub-property that indicates that invocation of an executor's execution
  47. /// function may block pending completion of one or more invocations of the
  48. /// submitted function object.
  49. struct possibly_t
  50. {
  51. /// The blocking_t::possibly_t property applies to executors.
  52. template <typename T>
  53. static constexpr bool is_applicable_property_v = is_executor_v<T>;
  54. /// The blocking_t::possibly_t property can be required.
  55. static constexpr bool is_requirable = true;
  56. /// The blocking_t::possibly_t property can be preferred.
  57. static constexpr bool is_preferable = true;
  58. /// The type returned by queries against an @c any_executor.
  59. typedef blocking_t polymorphic_query_result_type;
  60. /// Default constructor.
  61. constexpr possibly_t();
  62. /// Get the value associated with a property object.
  63. /**
  64. * @returns possibly_t();
  65. */
  66. static constexpr blocking_t value();
  67. };
  68. /// A sub-property that indicates that invocation of an executor's execution
  69. /// function shall block until completion of all invocations of the submitted
  70. /// function object.
  71. struct always_t
  72. {
  73. /// The blocking_t::always_t property applies to executors.
  74. template <typename T>
  75. static constexpr bool is_applicable_property_v = is_executor_v<T>;
  76. /// The blocking_t::always_t property can be required.
  77. static constexpr bool is_requirable = true;
  78. /// The blocking_t::always_t property can be preferred.
  79. static constexpr bool is_preferable = false;
  80. /// The type returned by queries against an @c any_executor.
  81. typedef blocking_t polymorphic_query_result_type;
  82. /// Default constructor.
  83. constexpr always_t();
  84. /// Get the value associated with a property object.
  85. /**
  86. * @returns always_t();
  87. */
  88. static constexpr blocking_t value();
  89. };
  90. /// A sub-property that indicates that invocation of an executor's execution
  91. /// function shall not block pending completion of the invocations of the
  92. /// submitted function object.
  93. struct never_t
  94. {
  95. /// The blocking_t::never_t property applies to executors.
  96. template <typename T>
  97. static constexpr bool is_applicable_property_v = is_executor_v<T>;
  98. /// The blocking_t::never_t property can be required.
  99. static constexpr bool is_requirable = true;
  100. /// The blocking_t::never_t property can be preferred.
  101. static constexpr bool is_preferable = true;
  102. /// The type returned by queries against an @c any_executor.
  103. typedef blocking_t polymorphic_query_result_type;
  104. /// Default constructor.
  105. constexpr never_t();
  106. /// Get the value associated with a property object.
  107. /**
  108. * @returns never_t();
  109. */
  110. static constexpr blocking_t value();
  111. };
  112. /// A special value used for accessing the blocking_t::possibly_t property.
  113. static constexpr possibly_t possibly;
  114. /// A special value used for accessing the blocking_t::always_t property.
  115. static constexpr always_t always;
  116. /// A special value used for accessing the blocking_t::never_t property.
  117. static constexpr never_t never;
  118. /// Default constructor.
  119. constexpr blocking_t();
  120. /// Construct from a sub-property value.
  121. constexpr blocking_t(possibly_t);
  122. /// Construct from a sub-property value.
  123. constexpr blocking_t(always_t);
  124. /// Construct from a sub-property value.
  125. constexpr blocking_t(never_t);
  126. /// Compare property values for equality.
  127. friend constexpr bool operator==(
  128. const blocking_t& a, const blocking_t& b) noexcept;
  129. /// Compare property values for inequality.
  130. friend constexpr bool operator!=(
  131. const blocking_t& a, const blocking_t& b) noexcept;
  132. };
  133. /// A special value used for accessing the blocking_t property.
  134. constexpr blocking_t blocking;
  135. } // namespace execution
  136. #else // defined(GENERATING_DOCUMENTATION)
  137. namespace execution {
  138. namespace detail {
  139. namespace blocking {
  140. template <int I> struct possibly_t;
  141. template <int I> struct always_t;
  142. template <int I> struct never_t;
  143. } // namespace blocking
  144. namespace blocking_adaptation {
  145. template <int I> struct allowed_t;
  146. template <typename Executor, typename Function>
  147. void blocking_execute(
  148. Executor&& ex,
  149. Function&& func);
  150. } // namespace blocking_adaptation
  151. template <int I = 0>
  152. struct blocking_t
  153. {
  154. #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
  155. template <typename T>
  156. static constexpr bool is_applicable_property_v = is_executor<T>::value;
  157. #endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
  158. static constexpr bool is_requirable = false;
  159. static constexpr bool is_preferable = false;
  160. typedef blocking_t polymorphic_query_result_type;
  161. typedef detail::blocking::possibly_t<I> possibly_t;
  162. typedef detail::blocking::always_t<I> always_t;
  163. typedef detail::blocking::never_t<I> never_t;
  164. constexpr blocking_t()
  165. : value_(-1)
  166. {
  167. }
  168. constexpr blocking_t(possibly_t)
  169. : value_(0)
  170. {
  171. }
  172. constexpr blocking_t(always_t)
  173. : value_(1)
  174. {
  175. }
  176. constexpr blocking_t(never_t)
  177. : value_(2)
  178. {
  179. }
  180. template <typename T>
  181. struct proxy
  182. {
  183. #if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
  184. struct type
  185. {
  186. template <typename P>
  187. auto query(P&& p) const
  188. noexcept(
  189. noexcept(
  190. declval<conditional_t<true, T, P>>().query(static_cast<P&&>(p))
  191. )
  192. )
  193. -> decltype(
  194. declval<conditional_t<true, T, P>>().query(static_cast<P&&>(p))
  195. );
  196. };
  197. #else // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
  198. typedef T type;
  199. #endif // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
  200. };
  201. template <typename T>
  202. struct static_proxy
  203. {
  204. #if defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
  205. struct type
  206. {
  207. template <typename P>
  208. static constexpr auto query(P&& p)
  209. noexcept(
  210. noexcept(
  211. conditional_t<true, T, P>::query(static_cast<P&&>(p))
  212. )
  213. )
  214. -> decltype(
  215. conditional_t<true, T, P>::query(static_cast<P&&>(p))
  216. )
  217. {
  218. return T::query(static_cast<P&&>(p));
  219. }
  220. };
  221. #else // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
  222. typedef T type;
  223. #endif // defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
  224. };
  225. template <typename T>
  226. struct query_member :
  227. traits::query_member<typename proxy<T>::type, blocking_t> {};
  228. template <typename T>
  229. struct query_static_constexpr_member :
  230. traits::query_static_constexpr_member<
  231. typename static_proxy<T>::type, blocking_t> {};
  232. #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
  233. && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  234. template <typename T>
  235. static constexpr
  236. typename query_static_constexpr_member<T>::result_type
  237. static_query()
  238. noexcept(query_static_constexpr_member<T>::is_noexcept)
  239. {
  240. return query_static_constexpr_member<T>::value();
  241. }
  242. template <typename T>
  243. static constexpr
  244. typename traits::static_query<T, possibly_t>::result_type
  245. static_query(
  246. enable_if_t<
  247. !query_static_constexpr_member<T>::is_valid
  248. >* = 0,
  249. enable_if_t<
  250. !query_member<T>::is_valid
  251. >* = 0,
  252. enable_if_t<
  253. traits::static_query<T, possibly_t>::is_valid
  254. >* = 0) noexcept
  255. {
  256. return traits::static_query<T, possibly_t>::value();
  257. }
  258. template <typename T>
  259. static constexpr
  260. typename traits::static_query<T, always_t>::result_type
  261. static_query(
  262. enable_if_t<
  263. !query_static_constexpr_member<T>::is_valid
  264. >* = 0,
  265. enable_if_t<
  266. !query_member<T>::is_valid
  267. >* = 0,
  268. enable_if_t<
  269. !traits::static_query<T, possibly_t>::is_valid
  270. >* = 0,
  271. enable_if_t<
  272. traits::static_query<T, always_t>::is_valid
  273. >* = 0) noexcept
  274. {
  275. return traits::static_query<T, always_t>::value();
  276. }
  277. template <typename T>
  278. static constexpr
  279. typename traits::static_query<T, never_t>::result_type
  280. static_query(
  281. enable_if_t<
  282. !query_static_constexpr_member<T>::is_valid
  283. >* = 0,
  284. enable_if_t<
  285. !query_member<T>::is_valid
  286. >* = 0,
  287. enable_if_t<
  288. !traits::static_query<T, possibly_t>::is_valid
  289. >* = 0,
  290. enable_if_t<
  291. !traits::static_query<T, always_t>::is_valid
  292. >* = 0,
  293. enable_if_t<
  294. traits::static_query<T, never_t>::is_valid
  295. >* = 0) noexcept
  296. {
  297. return traits::static_query<T, never_t>::value();
  298. }
  299. template <typename E, typename T = decltype(blocking_t::static_query<E>())>
  300. static constexpr const T static_query_v
  301. = blocking_t::static_query<E>();
  302. #endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
  303. // && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  304. friend constexpr bool operator==(
  305. const blocking_t& a, const blocking_t& b)
  306. {
  307. return a.value_ == b.value_;
  308. }
  309. friend constexpr bool operator!=(
  310. const blocking_t& a, const blocking_t& b)
  311. {
  312. return a.value_ != b.value_;
  313. }
  314. struct convertible_from_blocking_t
  315. {
  316. constexpr convertible_from_blocking_t(blocking_t) {}
  317. };
  318. template <typename Executor>
  319. friend constexpr blocking_t query(
  320. const Executor& ex, convertible_from_blocking_t,
  321. enable_if_t<
  322. can_query<const Executor&, possibly_t>::value
  323. >* = 0)
  324. #if !defined(__clang__) // Clang crashes if noexcept is used here.
  325. #if defined(BOOST_ASIO_MSVC) // Visual C++ wants the type to be qualified.
  326. noexcept(is_nothrow_query<const Executor&, blocking_t<>::possibly_t>::value)
  327. #else // defined(BOOST_ASIO_MSVC)
  328. noexcept(is_nothrow_query<const Executor&, possibly_t>::value)
  329. #endif // defined(BOOST_ASIO_MSVC)
  330. #endif // !defined(__clang__)
  331. {
  332. return boost::asio::query(ex, possibly_t());
  333. }
  334. template <typename Executor>
  335. friend constexpr blocking_t query(
  336. const Executor& ex, convertible_from_blocking_t,
  337. enable_if_t<
  338. !can_query<const Executor&, possibly_t>::value
  339. >* = 0,
  340. enable_if_t<
  341. can_query<const Executor&, always_t>::value
  342. >* = 0)
  343. #if !defined(__clang__) // Clang crashes if noexcept is used here.
  344. #if defined(BOOST_ASIO_MSVC) // Visual C++ wants the type to be qualified.
  345. noexcept(is_nothrow_query<const Executor&, blocking_t<>::always_t>::value)
  346. #else // defined(BOOST_ASIO_MSVC)
  347. noexcept(is_nothrow_query<const Executor&, always_t>::value)
  348. #endif // defined(BOOST_ASIO_MSVC)
  349. #endif // !defined(__clang__)
  350. {
  351. return boost::asio::query(ex, always_t());
  352. }
  353. template <typename Executor>
  354. friend constexpr blocking_t query(
  355. const Executor& ex, convertible_from_blocking_t,
  356. enable_if_t<
  357. !can_query<const Executor&, possibly_t>::value
  358. >* = 0,
  359. enable_if_t<
  360. !can_query<const Executor&, always_t>::value
  361. >* = 0,
  362. enable_if_t<
  363. can_query<const Executor&, never_t>::value
  364. >* = 0)
  365. #if !defined(__clang__) // Clang crashes if noexcept is used here.
  366. #if defined(BOOST_ASIO_MSVC) // Visual C++ wants the type to be qualified.
  367. noexcept(is_nothrow_query<const Executor&, blocking_t<>::never_t>::value)
  368. #else // defined(BOOST_ASIO_MSVC)
  369. noexcept(is_nothrow_query<const Executor&, never_t>::value)
  370. #endif // defined(BOOST_ASIO_MSVC)
  371. #endif // !defined(__clang__)
  372. {
  373. return boost::asio::query(ex, never_t());
  374. }
  375. BOOST_ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(possibly_t, possibly);
  376. BOOST_ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(always_t, always);
  377. BOOST_ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(never_t, never);
  378. private:
  379. int value_;
  380. };
  381. #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
  382. && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  383. template <int I> template <typename E, typename T>
  384. const T blocking_t<I>::static_query_v;
  385. #endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
  386. // && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  387. template <int I>
  388. const typename blocking_t<I>::possibly_t blocking_t<I>::possibly;
  389. template <int I>
  390. const typename blocking_t<I>::always_t blocking_t<I>::always;
  391. template <int I>
  392. const typename blocking_t<I>::never_t blocking_t<I>::never;
  393. namespace blocking {
  394. template <int I = 0>
  395. struct possibly_t
  396. {
  397. #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
  398. template <typename T>
  399. static constexpr bool is_applicable_property_v = is_executor<T>::value;
  400. #endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
  401. static constexpr bool is_requirable = true;
  402. static constexpr bool is_preferable = true;
  403. typedef blocking_t<I> polymorphic_query_result_type;
  404. constexpr possibly_t()
  405. {
  406. }
  407. template <typename T>
  408. struct query_member :
  409. traits::query_member<
  410. typename blocking_t<I>::template proxy<T>::type, possibly_t> {};
  411. template <typename T>
  412. struct query_static_constexpr_member :
  413. traits::query_static_constexpr_member<
  414. typename blocking_t<I>::template static_proxy<T>::type, possibly_t> {};
  415. #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
  416. && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  417. template <typename T>
  418. static constexpr
  419. typename query_static_constexpr_member<T>::result_type
  420. static_query()
  421. noexcept(query_static_constexpr_member<T>::is_noexcept)
  422. {
  423. return query_static_constexpr_member<T>::value();
  424. }
  425. template <typename T>
  426. static constexpr possibly_t static_query(
  427. enable_if_t<
  428. !query_static_constexpr_member<T>::is_valid
  429. >* = 0,
  430. enable_if_t<
  431. !query_member<T>::is_valid
  432. >* = 0,
  433. enable_if_t<
  434. !traits::query_free<T, possibly_t>::is_valid
  435. >* = 0,
  436. enable_if_t<
  437. !can_query<T, always_t<I>>::value
  438. >* = 0,
  439. enable_if_t<
  440. !can_query<T, never_t<I>>::value
  441. >* = 0) noexcept
  442. {
  443. return possibly_t();
  444. }
  445. template <typename E, typename T = decltype(possibly_t::static_query<E>())>
  446. static constexpr const T static_query_v
  447. = possibly_t::static_query<E>();
  448. #endif // defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  449. // && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  450. static constexpr blocking_t<I> value()
  451. {
  452. return possibly_t();
  453. }
  454. friend constexpr bool operator==(
  455. const possibly_t&, const possibly_t&)
  456. {
  457. return true;
  458. }
  459. friend constexpr bool operator!=(
  460. const possibly_t&, const possibly_t&)
  461. {
  462. return false;
  463. }
  464. friend constexpr bool operator==(
  465. const possibly_t&, const always_t<I>&)
  466. {
  467. return false;
  468. }
  469. friend constexpr bool operator!=(
  470. const possibly_t&, const always_t<I>&)
  471. {
  472. return true;
  473. }
  474. friend constexpr bool operator==(
  475. const possibly_t&, const never_t<I>&)
  476. {
  477. return false;
  478. }
  479. friend constexpr bool operator!=(
  480. const possibly_t&, const never_t<I>&)
  481. {
  482. return true;
  483. }
  484. };
  485. #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
  486. && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  487. template <int I> template <typename E, typename T>
  488. const T possibly_t<I>::static_query_v;
  489. #endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
  490. // && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  491. template <typename Executor>
  492. class adapter
  493. {
  494. public:
  495. adapter(int, const Executor& e) noexcept
  496. : executor_(e)
  497. {
  498. }
  499. adapter(const adapter& other) noexcept
  500. : executor_(other.executor_)
  501. {
  502. }
  503. adapter(adapter&& other) noexcept
  504. : executor_(static_cast<Executor&&>(other.executor_))
  505. {
  506. }
  507. template <int I>
  508. static constexpr always_t<I> query(blocking_t<I>) noexcept
  509. {
  510. return always_t<I>();
  511. }
  512. template <int I>
  513. static constexpr always_t<I> query(possibly_t<I>) noexcept
  514. {
  515. return always_t<I>();
  516. }
  517. template <int I>
  518. static constexpr always_t<I> query(always_t<I>) noexcept
  519. {
  520. return always_t<I>();
  521. }
  522. template <int I>
  523. static constexpr always_t<I> query(never_t<I>) noexcept
  524. {
  525. return always_t<I>();
  526. }
  527. template <typename Property>
  528. enable_if_t<
  529. can_query<const Executor&, Property>::value,
  530. query_result_t<const Executor&, Property>
  531. > query(const Property& p) const
  532. noexcept(is_nothrow_query<const Executor&, Property>::value)
  533. {
  534. return boost::asio::query(executor_, p);
  535. }
  536. template <int I>
  537. enable_if_t<
  538. can_require<const Executor&, possibly_t<I>>::value,
  539. require_result_t<const Executor&, possibly_t<I>>
  540. > require(possibly_t<I>) const noexcept
  541. {
  542. return boost::asio::require(executor_, possibly_t<I>());
  543. }
  544. template <int I>
  545. enable_if_t<
  546. can_require<const Executor&, never_t<I>>::value,
  547. require_result_t<const Executor&, never_t<I>>
  548. > require(never_t<I>) const noexcept
  549. {
  550. return boost::asio::require(executor_, never_t<I>());
  551. }
  552. template <typename Property>
  553. enable_if_t<
  554. can_require<const Executor&, Property>::value,
  555. adapter<decay_t<require_result_t<const Executor&, Property>>>
  556. > require(const Property& p) const
  557. noexcept(is_nothrow_require<const Executor&, Property>::value)
  558. {
  559. return adapter<decay_t<require_result_t<const Executor&, Property>>>(
  560. 0, boost::asio::require(executor_, p));
  561. }
  562. template <typename Property>
  563. enable_if_t<
  564. can_prefer<const Executor&, Property>::value,
  565. adapter<decay_t<prefer_result_t<const Executor&, Property>>>
  566. > prefer(const Property& p) const
  567. noexcept(is_nothrow_prefer<const Executor&, Property>::value)
  568. {
  569. return adapter<decay_t<prefer_result_t<const Executor&, Property>>>(
  570. 0, boost::asio::prefer(executor_, p));
  571. }
  572. template <typename Function>
  573. enable_if_t<
  574. traits::execute_member<const Executor&, Function>::is_valid
  575. > execute(Function&& f) const
  576. {
  577. blocking_adaptation::blocking_execute(
  578. executor_, static_cast<Function&&>(f));
  579. }
  580. friend bool operator==(const adapter& a, const adapter& b) noexcept
  581. {
  582. return a.executor_ == b.executor_;
  583. }
  584. friend bool operator!=(const adapter& a, const adapter& b) noexcept
  585. {
  586. return a.executor_ != b.executor_;
  587. }
  588. private:
  589. Executor executor_;
  590. };
  591. template <int I = 0>
  592. struct always_t
  593. {
  594. #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
  595. template <typename T>
  596. static constexpr bool is_applicable_property_v = is_executor<T>::value;
  597. #endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
  598. static constexpr bool is_requirable = true;
  599. static constexpr bool is_preferable = false;
  600. typedef blocking_t<I> polymorphic_query_result_type;
  601. constexpr always_t()
  602. {
  603. }
  604. template <typename T>
  605. struct query_member :
  606. traits::query_member<
  607. typename blocking_t<I>::template proxy<T>::type, always_t> {};
  608. template <typename T>
  609. struct query_static_constexpr_member :
  610. traits::query_static_constexpr_member<
  611. typename blocking_t<I>::template static_proxy<T>::type, always_t> {};
  612. #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
  613. && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  614. template <typename T>
  615. static constexpr typename query_static_constexpr_member<T>::result_type
  616. static_query()
  617. noexcept(query_static_constexpr_member<T>::is_noexcept)
  618. {
  619. return query_static_constexpr_member<T>::value();
  620. }
  621. template <typename E, typename T = decltype(always_t::static_query<E>())>
  622. static constexpr const T static_query_v = always_t::static_query<E>();
  623. #endif // defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  624. // && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  625. static constexpr blocking_t<I> value()
  626. {
  627. return always_t();
  628. }
  629. friend constexpr bool operator==(
  630. const always_t&, const always_t&)
  631. {
  632. return true;
  633. }
  634. friend constexpr bool operator!=(
  635. const always_t&, const always_t&)
  636. {
  637. return false;
  638. }
  639. friend constexpr bool operator==(
  640. const always_t&, const possibly_t<I>&)
  641. {
  642. return false;
  643. }
  644. friend constexpr bool operator!=(
  645. const always_t&, const possibly_t<I>&)
  646. {
  647. return true;
  648. }
  649. friend constexpr bool operator==(
  650. const always_t&, const never_t<I>&)
  651. {
  652. return false;
  653. }
  654. friend constexpr bool operator!=(
  655. const always_t&, const never_t<I>&)
  656. {
  657. return true;
  658. }
  659. template <typename Executor>
  660. friend adapter<Executor> require(
  661. const Executor& e, const always_t&,
  662. enable_if_t<
  663. is_executor<Executor>::value
  664. >* = 0,
  665. enable_if_t<
  666. traits::static_require<
  667. const Executor&,
  668. blocking_adaptation::allowed_t<0>
  669. >::is_valid
  670. >* = 0)
  671. {
  672. return adapter<Executor>(0, e);
  673. }
  674. };
  675. #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
  676. && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  677. template <int I> template <typename E, typename T>
  678. const T always_t<I>::static_query_v;
  679. #endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
  680. // && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  681. template <int I>
  682. struct never_t
  683. {
  684. #if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
  685. template <typename T>
  686. static constexpr bool is_applicable_property_v = is_executor<T>::value;
  687. #endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
  688. static constexpr bool is_requirable = true;
  689. static constexpr bool is_preferable = true;
  690. typedef blocking_t<I> polymorphic_query_result_type;
  691. constexpr never_t()
  692. {
  693. }
  694. template <typename T>
  695. struct query_member :
  696. traits::query_member<
  697. typename blocking_t<I>::template proxy<T>::type, never_t> {};
  698. template <typename T>
  699. struct query_static_constexpr_member :
  700. traits::query_static_constexpr_member<
  701. typename blocking_t<I>::template static_proxy<T>::type, never_t> {};
  702. #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
  703. && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  704. template <typename T>
  705. static constexpr
  706. typename query_static_constexpr_member<T>::result_type
  707. static_query()
  708. noexcept(query_static_constexpr_member<T>::is_noexcept)
  709. {
  710. return query_static_constexpr_member<T>::value();
  711. }
  712. template <typename E, typename T = decltype(never_t::static_query<E>())>
  713. static constexpr const T static_query_v
  714. = never_t::static_query<E>();
  715. #endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
  716. // && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  717. static constexpr blocking_t<I> value()
  718. {
  719. return never_t();
  720. }
  721. friend constexpr bool operator==(const never_t&, const never_t&)
  722. {
  723. return true;
  724. }
  725. friend constexpr bool operator!=(const never_t&, const never_t&)
  726. {
  727. return false;
  728. }
  729. friend constexpr bool operator==(const never_t&, const possibly_t<I>&)
  730. {
  731. return false;
  732. }
  733. friend constexpr bool operator!=(const never_t&, const possibly_t<I>&)
  734. {
  735. return true;
  736. }
  737. friend constexpr bool operator==(const never_t&, const always_t<I>&)
  738. {
  739. return false;
  740. }
  741. friend constexpr bool operator!=(const never_t&, const always_t<I>&)
  742. {
  743. return true;
  744. }
  745. };
  746. #if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
  747. && defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  748. template <int I> template <typename E, typename T>
  749. const T never_t<I>::static_query_v;
  750. #endif // defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  751. } // namespace blocking
  752. } // namespace detail
  753. typedef detail::blocking_t<> blocking_t;
  754. BOOST_ASIO_INLINE_VARIABLE constexpr blocking_t blocking;
  755. } // namespace execution
  756. #if !defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
  757. template <typename T>
  758. struct is_applicable_property<T, execution::blocking_t>
  759. : integral_constant<bool, execution::is_executor<T>::value>
  760. {
  761. };
  762. template <typename T>
  763. struct is_applicable_property<T, execution::blocking_t::possibly_t>
  764. : integral_constant<bool, execution::is_executor<T>::value>
  765. {
  766. };
  767. template <typename T>
  768. struct is_applicable_property<T, execution::blocking_t::always_t>
  769. : integral_constant<bool, execution::is_executor<T>::value>
  770. {
  771. };
  772. template <typename T>
  773. struct is_applicable_property<T, execution::blocking_t::never_t>
  774. : integral_constant<bool, execution::is_executor<T>::value>
  775. {
  776. };
  777. #endif // !defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
  778. namespace traits {
  779. #if !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
  780. template <typename T>
  781. struct query_free_default<T, execution::blocking_t,
  782. enable_if_t<
  783. can_query<T, execution::blocking_t::possibly_t>::value
  784. >>
  785. {
  786. static constexpr bool is_valid = true;
  787. static constexpr bool is_noexcept =
  788. is_nothrow_query<T, execution::blocking_t::possibly_t>::value;
  789. typedef execution::blocking_t result_type;
  790. };
  791. template <typename T>
  792. struct query_free_default<T, execution::blocking_t,
  793. enable_if_t<
  794. !can_query<T, execution::blocking_t::possibly_t>::value
  795. && can_query<T, execution::blocking_t::always_t>::value
  796. >>
  797. {
  798. static constexpr bool is_valid = true;
  799. static constexpr bool is_noexcept =
  800. is_nothrow_query<T, execution::blocking_t::always_t>::value;
  801. typedef execution::blocking_t result_type;
  802. };
  803. template <typename T>
  804. struct query_free_default<T, execution::blocking_t,
  805. enable_if_t<
  806. !can_query<T, execution::blocking_t::possibly_t>::value
  807. && !can_query<T, execution::blocking_t::always_t>::value
  808. && can_query<T, execution::blocking_t::never_t>::value
  809. >>
  810. {
  811. static constexpr bool is_valid = true;
  812. static constexpr bool is_noexcept =
  813. is_nothrow_query<T, execution::blocking_t::never_t>::value;
  814. typedef execution::blocking_t result_type;
  815. };
  816. #endif // !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT)
  817. #if !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \
  818. || !defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  819. template <typename T>
  820. struct static_query<T, execution::blocking_t,
  821. enable_if_t<
  822. execution::detail::blocking_t<0>::
  823. query_static_constexpr_member<T>::is_valid
  824. >>
  825. {
  826. static constexpr bool is_valid = true;
  827. static constexpr bool is_noexcept = true;
  828. typedef typename execution::detail::blocking_t<0>::
  829. query_static_constexpr_member<T>::result_type result_type;
  830. static constexpr result_type value()
  831. {
  832. return execution::blocking_t::query_static_constexpr_member<T>::value();
  833. }
  834. };
  835. template <typename T>
  836. struct static_query<T, execution::blocking_t,
  837. enable_if_t<
  838. !execution::detail::blocking_t<0>::
  839. query_static_constexpr_member<T>::is_valid
  840. && !execution::detail::blocking_t<0>::
  841. query_member<T>::is_valid
  842. && traits::static_query<T, execution::blocking_t::possibly_t>::is_valid
  843. >>
  844. {
  845. static constexpr bool is_valid = true;
  846. static constexpr bool is_noexcept = true;
  847. typedef typename traits::static_query<T,
  848. execution::blocking_t::possibly_t>::result_type result_type;
  849. static constexpr result_type value()
  850. {
  851. return traits::static_query<T, execution::blocking_t::possibly_t>::value();
  852. }
  853. };
  854. template <typename T>
  855. struct static_query<T, execution::blocking_t,
  856. enable_if_t<
  857. !execution::detail::blocking_t<0>::
  858. query_static_constexpr_member<T>::is_valid
  859. && !execution::detail::blocking_t<0>::
  860. query_member<T>::is_valid
  861. && !traits::static_query<T, execution::blocking_t::possibly_t>::is_valid
  862. && traits::static_query<T, execution::blocking_t::always_t>::is_valid
  863. >>
  864. {
  865. static constexpr bool is_valid = true;
  866. static constexpr bool is_noexcept = true;
  867. typedef typename traits::static_query<T,
  868. execution::blocking_t::always_t>::result_type result_type;
  869. static constexpr result_type value()
  870. {
  871. return traits::static_query<T, execution::blocking_t::always_t>::value();
  872. }
  873. };
  874. template <typename T>
  875. struct static_query<T, execution::blocking_t,
  876. enable_if_t<
  877. !execution::detail::blocking_t<0>::
  878. query_static_constexpr_member<T>::is_valid
  879. && !execution::detail::blocking_t<0>::
  880. query_member<T>::is_valid
  881. && !traits::static_query<T, execution::blocking_t::possibly_t>::is_valid
  882. && !traits::static_query<T, execution::blocking_t::always_t>::is_valid
  883. && traits::static_query<T, execution::blocking_t::never_t>::is_valid
  884. >>
  885. {
  886. static constexpr bool is_valid = true;
  887. static constexpr bool is_noexcept = true;
  888. typedef typename traits::static_query<T,
  889. execution::blocking_t::never_t>::result_type result_type;
  890. static constexpr result_type value()
  891. {
  892. return traits::static_query<T, execution::blocking_t::never_t>::value();
  893. }
  894. };
  895. template <typename T>
  896. struct static_query<T, execution::blocking_t::possibly_t,
  897. enable_if_t<
  898. execution::detail::blocking::possibly_t<0>::
  899. query_static_constexpr_member<T>::is_valid
  900. >>
  901. {
  902. static constexpr bool is_valid = true;
  903. static constexpr bool is_noexcept = true;
  904. typedef typename execution::detail::blocking::possibly_t<0>::
  905. query_static_constexpr_member<T>::result_type result_type;
  906. static constexpr result_type value()
  907. {
  908. return execution::detail::blocking::possibly_t<0>::
  909. query_static_constexpr_member<T>::value();
  910. }
  911. };
  912. template <typename T>
  913. struct static_query<T, execution::blocking_t::possibly_t,
  914. enable_if_t<
  915. !execution::detail::blocking::possibly_t<0>::
  916. query_static_constexpr_member<T>::is_valid
  917. && !execution::detail::blocking::possibly_t<0>::
  918. query_member<T>::is_valid
  919. && !traits::query_free<T, execution::blocking_t::possibly_t>::is_valid
  920. && !can_query<T, execution::blocking_t::always_t>::value
  921. && !can_query<T, execution::blocking_t::never_t>::value
  922. >>
  923. {
  924. static constexpr bool is_valid = true;
  925. static constexpr bool is_noexcept = true;
  926. typedef execution::blocking_t::possibly_t result_type;
  927. static constexpr result_type value()
  928. {
  929. return result_type();
  930. }
  931. };
  932. template <typename T>
  933. struct static_query<T, execution::blocking_t::always_t,
  934. enable_if_t<
  935. execution::detail::blocking::always_t<0>::
  936. query_static_constexpr_member<T>::is_valid
  937. >>
  938. {
  939. static constexpr bool is_valid = true;
  940. static constexpr bool is_noexcept = true;
  941. typedef typename execution::detail::blocking::always_t<0>::
  942. query_static_constexpr_member<T>::result_type result_type;
  943. static constexpr result_type value()
  944. {
  945. return execution::detail::blocking::always_t<0>::
  946. query_static_constexpr_member<T>::value();
  947. }
  948. };
  949. template <typename T>
  950. struct static_query<T, execution::blocking_t::never_t,
  951. enable_if_t<
  952. execution::detail::blocking::never_t<0>::
  953. query_static_constexpr_member<T>::is_valid
  954. >>
  955. {
  956. static constexpr bool is_valid = true;
  957. static constexpr bool is_noexcept = true;
  958. typedef typename execution::detail::blocking::never_t<0>::
  959. query_static_constexpr_member<T>::result_type result_type;
  960. static constexpr result_type value()
  961. {
  962. return execution::detail::blocking::never_t<0>::
  963. query_static_constexpr_member<T>::value();
  964. }
  965. };
  966. #endif // !defined(BOOST_ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT)
  967. // || !defined(BOOST_ASIO_HAS_SFINAE_VARIABLE_TEMPLATES)
  968. #if !defined(BOOST_ASIO_HAS_DEDUCED_REQUIRE_FREE_TRAIT)
  969. template <typename T>
  970. struct require_free_default<T, execution::blocking_t::always_t,
  971. enable_if_t<
  972. is_same<T, decay_t<T>>::value
  973. && execution::is_executor<T>::value
  974. && traits::static_require<
  975. const T&,
  976. execution::detail::blocking_adaptation::allowed_t<0>
  977. >::is_valid
  978. >>
  979. {
  980. static constexpr bool is_valid = true;
  981. static constexpr bool is_noexcept = false;
  982. typedef execution::detail::blocking::adapter<T> result_type;
  983. };
  984. #endif // !defined(BOOST_ASIO_HAS_DEDUCED_REQUIRE_FREE_TRAIT)
  985. #if !defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
  986. template <typename Executor>
  987. struct equality_comparable<
  988. execution::detail::blocking::adapter<Executor>>
  989. {
  990. static constexpr bool is_valid = true;
  991. static constexpr bool is_noexcept = true;
  992. };
  993. #endif // !defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
  994. #if !defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
  995. template <typename Executor, typename Function>
  996. struct execute_member<
  997. execution::detail::blocking::adapter<Executor>, Function>
  998. {
  999. static constexpr bool is_valid = true;
  1000. static constexpr bool is_noexcept = false;
  1001. typedef void result_type;
  1002. };
  1003. #endif // !defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
  1004. #if !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
  1005. template <typename Executor, int I>
  1006. struct query_static_constexpr_member<
  1007. execution::detail::blocking::adapter<Executor>,
  1008. execution::detail::blocking_t<I>>
  1009. {
  1010. static constexpr bool is_valid = true;
  1011. static constexpr bool is_noexcept = true;
  1012. typedef execution::blocking_t::always_t result_type;
  1013. static constexpr result_type value() noexcept
  1014. {
  1015. return result_type();
  1016. }
  1017. };
  1018. template <typename Executor, int I>
  1019. struct query_static_constexpr_member<
  1020. execution::detail::blocking::adapter<Executor>,
  1021. execution::detail::blocking::always_t<I>>
  1022. {
  1023. static constexpr bool is_valid = true;
  1024. static constexpr bool is_noexcept = true;
  1025. typedef execution::blocking_t::always_t result_type;
  1026. static constexpr result_type value() noexcept
  1027. {
  1028. return result_type();
  1029. }
  1030. };
  1031. template <typename Executor, int I>
  1032. struct query_static_constexpr_member<
  1033. execution::detail::blocking::adapter<Executor>,
  1034. execution::detail::blocking::possibly_t<I>>
  1035. {
  1036. static constexpr bool is_valid = true;
  1037. static constexpr bool is_noexcept = true;
  1038. typedef execution::blocking_t::always_t result_type;
  1039. static constexpr result_type value() noexcept
  1040. {
  1041. return result_type();
  1042. }
  1043. };
  1044. template <typename Executor, int I>
  1045. struct query_static_constexpr_member<
  1046. execution::detail::blocking::adapter<Executor>,
  1047. execution::detail::blocking::never_t<I>>
  1048. {
  1049. static constexpr bool is_valid = true;
  1050. static constexpr bool is_noexcept = true;
  1051. typedef execution::blocking_t::always_t result_type;
  1052. static constexpr result_type value() noexcept
  1053. {
  1054. return result_type();
  1055. }
  1056. };
  1057. #endif // !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_STATIC_CONSTEXPR_MEMBER_TRAIT)
  1058. #if !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
  1059. template <typename Executor, typename Property>
  1060. struct query_member<
  1061. execution::detail::blocking::adapter<Executor>, Property,
  1062. enable_if_t<
  1063. can_query<const Executor&, Property>::value
  1064. >>
  1065. {
  1066. static constexpr bool is_valid = true;
  1067. static constexpr bool is_noexcept =
  1068. is_nothrow_query<Executor, Property>::value;
  1069. typedef query_result_t<Executor, Property> result_type;
  1070. };
  1071. #endif // !defined(BOOST_ASIO_HAS_DEDUCED_QUERY_MEMBER_TRAIT)
  1072. #if !defined(BOOST_ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT)
  1073. template <typename Executor, int I>
  1074. struct require_member<
  1075. execution::detail::blocking::adapter<Executor>,
  1076. execution::detail::blocking::possibly_t<I>,
  1077. enable_if_t<
  1078. can_require<
  1079. const Executor&,
  1080. execution::detail::blocking::possibly_t<I>
  1081. >::value
  1082. >>
  1083. {
  1084. static constexpr bool is_valid = true;
  1085. static constexpr bool is_noexcept =
  1086. is_nothrow_require<const Executor&,
  1087. execution::detail::blocking::possibly_t<I>>::value;
  1088. typedef require_result_t<const Executor&,
  1089. execution::detail::blocking::possibly_t<I>> result_type;
  1090. };
  1091. template <typename Executor, int I>
  1092. struct require_member<
  1093. execution::detail::blocking::adapter<Executor>,
  1094. execution::detail::blocking::never_t<I>,
  1095. enable_if_t<
  1096. can_require<
  1097. const Executor&,
  1098. execution::detail::blocking::never_t<I>
  1099. >::value
  1100. >>
  1101. {
  1102. static constexpr bool is_valid = true;
  1103. static constexpr bool is_noexcept =
  1104. is_nothrow_require<const Executor&,
  1105. execution::detail::blocking::never_t<I>>::value;
  1106. typedef require_result_t<const Executor&,
  1107. execution::detail::blocking::never_t<I>> result_type;
  1108. };
  1109. template <typename Executor, typename Property>
  1110. struct require_member<
  1111. execution::detail::blocking::adapter<Executor>, Property,
  1112. enable_if_t<
  1113. can_require<const Executor&, Property>::value
  1114. >>
  1115. {
  1116. static constexpr bool is_valid = true;
  1117. static constexpr bool is_noexcept =
  1118. is_nothrow_require<Executor, Property>::value;
  1119. typedef execution::detail::blocking::adapter<
  1120. decay_t<require_result_t<Executor, Property>>> result_type;
  1121. };
  1122. #endif // !defined(BOOST_ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT)
  1123. #if !defined(BOOST_ASIO_HAS_DEDUCED_PREFER_MEMBER_TRAIT)
  1124. template <typename Executor, typename Property>
  1125. struct prefer_member<
  1126. execution::detail::blocking::adapter<Executor>, Property,
  1127. enable_if_t<
  1128. can_prefer<const Executor&, Property>::value
  1129. >>
  1130. {
  1131. static constexpr bool is_valid = true;
  1132. static constexpr bool is_noexcept =
  1133. is_nothrow_prefer<Executor, Property>::value;
  1134. typedef execution::detail::blocking::adapter<
  1135. decay_t<prefer_result_t<Executor, Property>>> result_type;
  1136. };
  1137. #endif // !defined(BOOST_ASIO_HAS_DEDUCED_PREFER_MEMBER_TRAIT)
  1138. } // namespace traits
  1139. #endif // defined(GENERATING_DOCUMENTATION)
  1140. } // namespace asio
  1141. } // namespace boost
  1142. #include <boost/asio/detail/pop_options.hpp>
  1143. #endif // BOOST_ASIO_EXECUTION_BLOCKING_HPP