11 #ifndef ASIO_EXECUTION_RELATIONSHIP_HPP 12 #define ASIO_EXECUTION_RELATIONSHIP_HPP 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 18 #include "asio/detail/config.hpp" 19 #include "asio/detail/type_traits.hpp" 20 #include "asio/execution/executor.hpp" 21 #include "asio/execution/scheduler.hpp" 22 #include "asio/execution/sender.hpp" 23 #include "asio/is_applicable_property.hpp" 24 #include "asio/query.hpp" 25 #include "asio/traits/query_free.hpp" 26 #include "asio/traits/query_member.hpp" 27 #include "asio/traits/query_static_constexpr_member.hpp" 28 #include "asio/traits/static_query.hpp" 29 #include "asio/traits/static_require.hpp" 31 #include "asio/detail/push_options.hpp" 35 #if defined(GENERATING_DOCUMENTATION) 45 static constexpr
bool is_applicable_property_v =
46 is_executor_v<T> || is_sender_v<T> || is_scheduler_v<T>;
49 static constexpr
bool is_requirable =
false;
52 static constexpr
bool is_preferable =
false;
55 typedef relationship_t polymorphic_query_result_type;
64 static constexpr
bool is_applicable_property_v =
65 is_executor_v<T> || is_sender_v<T> || is_scheduler_v<T>;
68 static constexpr
bool is_requirable =
true;
71 static constexpr
bool is_preferable =
true;
74 typedef relationship_t polymorphic_query_result_type;
83 static constexpr relationship_t value();
93 static constexpr
bool is_applicable_property_v =
94 is_executor_v<T> || is_sender_v<T> || is_scheduler_v<T>;
97 static constexpr
bool is_requirable =
true;
100 static constexpr
bool is_preferable =
true;
103 typedef relationship_t polymorphic_query_result_type;
106 constexpr continuation_t();
112 static constexpr relationship_t value();
116 static constexpr fork_t fork;
120 static constexpr continuation_t continuation;
123 constexpr relationship_t();
126 constexpr relationship_t(fork_t);
129 constexpr relationship_t(continuation_t);
132 friend constexpr
bool operator==(
133 const relationship_t& a,
const relationship_t& b) noexcept;
136 friend constexpr
bool operator!=(
137 const relationship_t& a,
const relationship_t& b) noexcept;
141 constexpr relationship_t relationship;
145 #else // defined(GENERATING_DOCUMENTATION) 149 namespace relationship {
159 #if defined(ASIO_HAS_VARIABLE_TEMPLATES) 160 template <
typename T>
161 ASIO_STATIC_CONSTEXPR(
bool,
164 #endif // defined(ASIO_HAS_VARIABLE_TEMPLATES) 178 ASIO_CONSTEXPR relationship_t(fork_t)
183 ASIO_CONSTEXPR relationship_t(continuation_t)
188 #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 189 && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 190 template <
typename T>
191 static ASIO_CONSTEXPR
193 T, relationship_t>::result_type
201 T, relationship_t>::value();
204 template <
typename T>
205 static ASIO_CONSTEXPR
210 T, relationship_t>::is_valid
213 >::type* = 0) ASIO_NOEXCEPT
218 template <
typename T>
219 static ASIO_CONSTEXPR
224 T, relationship_t>::is_valid
228 >::type* = 0) ASIO_NOEXCEPT
233 template <
typename E,
234 typename T = decltype(relationship_t::static_query<E>())>
235 static ASIO_CONSTEXPR
const T static_query_v
236 = relationship_t::static_query<E>();
237 #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 240 friend ASIO_CONSTEXPR
bool operator==(
241 const relationship_t& a,
const relationship_t& b)
243 return a.value_ == b.value_;
246 friend ASIO_CONSTEXPR
bool operator!=(
247 const relationship_t& a,
const relationship_t& b)
249 return a.value_ != b.value_;
259 template <
typename Executor>
260 friend ASIO_CONSTEXPR relationship_t query(
265 #if !defined(__clang__) // Clang crashes if noexcept is used here. 266 #if defined(ASIO_MSVC) // Visual C++ wants the type to be qualified. 269 #else // defined(ASIO_MSVC) 272 #endif // defined(ASIO_MSVC) 273 #endif // !defined(__clang__) 275 return asio::query(ex, fork_t());
278 template <
typename Executor>
279 friend ASIO_CONSTEXPR relationship_t query(
285 #if !defined(__clang__) // Clang crashes if noexcept is used here. 286 #if defined(ASIO_MSVC) // Visual C++ wants the type to be qualified. 290 #else // defined(ASIO_MSVC) 293 #endif // defined(ASIO_MSVC) 294 #endif // !defined(__clang__) 296 return asio::query(ex, continuation_t());
299 ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(fork_t, fork);
300 ASIO_STATIC_CONSTEXPR_DEFAULT_INIT(continuation_t, continuation);
302 #if !defined(ASIO_HAS_CONSTEXPR) 303 static const relationship_t instance;
304 #endif // !defined(ASIO_HAS_CONSTEXPR) 310 #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 311 && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 312 template <
int I>
template <
typename E,
typename T>
314 #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 317 #if !defined(ASIO_HAS_CONSTEXPR) 330 namespace relationship {
335 #if defined(ASIO_HAS_VARIABLE_TEMPLATES) 336 template <
typename T>
337 ASIO_STATIC_CONSTEXPR(
bool,
340 #endif // defined(ASIO_HAS_VARIABLE_TEMPLATES) 350 #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 351 && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 352 template <
typename T>
353 static ASIO_CONSTEXPR
362 template <
typename T>
363 static ASIO_CONSTEXPR
fork_t static_query(
369 >::type* = 0) ASIO_NOEXCEPT
374 template <
typename E,
typename T = decltype(fork_t::static_query<E>())>
375 static ASIO_CONSTEXPR
const T static_query_v
376 = fork_t::static_query<E>();
377 #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 385 friend ASIO_CONSTEXPR
bool operator==(
391 friend ASIO_CONSTEXPR
bool operator!=(
398 #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 399 && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 400 template <
int I>
template <
typename E,
typename T>
402 #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 408 #if defined(ASIO_HAS_VARIABLE_TEMPLATES) 409 template <
typename T>
410 ASIO_STATIC_CONSTEXPR(
bool,
413 #endif // defined(ASIO_HAS_VARIABLE_TEMPLATES) 423 #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 424 && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 425 template <
typename T>
426 static ASIO_CONSTEXPR
435 template <
typename E,
436 typename T = decltype(continuation_t::static_query<E>())>
437 static ASIO_CONSTEXPR
const T static_query_v
438 = continuation_t::static_query<E>();
439 #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 447 friend ASIO_CONSTEXPR
bool operator==(
453 friend ASIO_CONSTEXPR
bool operator!=(
460 #if defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 461 && defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 462 template <
int I>
template <
typename E,
typename T>
464 #endif // defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 472 #if defined(ASIO_HAS_CONSTEXPR) || defined(GENERATING_DOCUMENTATION) 473 constexpr relationship_t relationship;
474 #else // defined(ASIO_HAS_CONSTEXPR) || defined(GENERATING_DOCUMENTATION) 475 namespace {
static const relationship_t&
476 relationship = relationship_t::instance; }
481 #if !defined(ASIO_HAS_VARIABLE_TEMPLATES) 483 template <
typename T>
485 : integral_constant<bool,
486 execution::is_executor<T>::value
487 || execution::is_sender<T>::value
488 || execution::is_scheduler<T>::value>
492 template <
typename T>
494 : integral_constant<bool,
495 execution::is_executor<T>::value
496 || execution::is_sender<T>::value
497 || execution::is_scheduler<T>::value>
501 template <
typename T>
503 : integral_constant<bool,
504 execution::is_executor<T>::value
505 || execution::is_sender<T>::value
506 || execution::is_scheduler<T>::value>
510 #endif // !defined(ASIO_HAS_VARIABLE_TEMPLATES) 514 #if !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) 516 template <
typename T>
519 can_query<T, execution::relationship_t::fork_t>::value
522 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
523 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
529 template <
typename T>
532 !can_query<T, execution::relationship_t::fork_t>::value
533 && can_query<T, execution::relationship_t::continuation_t>::value
536 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
537 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
543 #endif // !defined(ASIO_HAS_DEDUCED_QUERY_FREE_TRAIT) 545 #if !defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) \ 546 || !defined(ASIO_HAS_SFINAE_VARIABLE_TEMPLATES) 548 template <
typename T>
551 traits::query_static_constexpr_member<T,
552 execution::relationship_t>::is_valid
555 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
556 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
true);
561 static ASIO_CONSTEXPR result_type value()
568 template <
typename T>
571 !traits::query_static_constexpr_member<T,
572 execution::relationship_t>::is_valid
573 && !traits::query_member<T,
574 execution::relationship_t>::is_valid
575 && traits::static_query<T,
576 execution::relationship_t::fork_t>::is_valid
579 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
580 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
true);
585 static ASIO_CONSTEXPR result_type value()
592 template <
typename T>
595 !traits::query_static_constexpr_member<T,
596 execution::relationship_t>::is_valid
597 && !traits::query_member<T,
598 execution::relationship_t>::is_valid
599 && !traits::static_query<T,
600 execution::relationship_t::fork_t>::is_valid
601 && traits::static_query<T,
602 execution::relationship_t::continuation_t>::is_valid
605 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
606 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
true);
611 static ASIO_CONSTEXPR result_type value()
618 template <
typename T>
621 traits::query_static_constexpr_member<T,
622 execution::relationship_t::fork_t>::is_valid
625 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
626 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
true);
631 static ASIO_CONSTEXPR result_type value()
638 template <
typename T>
641 !traits::query_static_constexpr_member<T,
642 execution::relationship_t::fork_t>::is_valid
643 && !traits::query_member<T,
644 execution::relationship_t::fork_t>::is_valid
645 && !traits::query_free<T,
646 execution::relationship_t::fork_t>::is_valid
647 && !can_query<T, execution::relationship_t::continuation_t>::value
650 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
651 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
true);
655 static ASIO_CONSTEXPR result_type value()
657 return result_type();
661 template <
typename T>
664 traits::query_static_constexpr_member<T,
665 execution::relationship_t::continuation_t>::is_valid
668 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
true);
669 ASIO_STATIC_CONSTEXPR(
bool, is_noexcept =
true);
674 static ASIO_CONSTEXPR result_type value()
681 #endif // !defined(ASIO_HAS_DEDUCED_STATIC_QUERY_TRAIT) 684 #if !defined(ASIO_HAS_DEDUCED_STATIC_REQUIRE_TRAIT) 686 template <
typename T>
689 static_query<T, execution::relationship_t::fork_t>::is_valid
692 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
698 template <
typename T>
701 static_query<T, execution::relationship_t::continuation_t>::is_valid
704 ASIO_STATIC_CONSTEXPR(
bool, is_valid =
710 #endif // !defined(ASIO_HAS_DEDUCED_STATIC_REQUIRE_TRAIT) 714 #endif // defined(GENERATING_DOCUMENTATION) 718 #include "asio/detail/pop_options.hpp" 720 #endif // ASIO_EXECUTION_RELATIONSHIP_HPP Definition: static_require.hpp:37
Definition: relationship.hpp:157
Definition: any_executor.hpp:249
Definition: query.hpp:269
The is_scheduler trait detects whether a type T satisfies the execution::scheduler concept...
Definition: scheduler.hpp:48
The is_sender trait detects whether a type T satisfies the execution::sender concept.
Definition: sender.hpp:183
Definition: query_member.hpp:38
Definition: static_query.hpp:42
Definition: type_traits.hpp:97
Definition: query.hpp:253
Definition: query_free.hpp:35
Definition: relationship.hpp:152
Definition: query_free.hpp:38
Definition: query_static_constexpr_member.hpp:42
Definition: any_executor.hpp:256
Definition: relationship.hpp:252
Definition: handler_work.hpp:37
Definition: relationship.hpp:151
Definition: is_applicable_property.hpp:46
Definition: any_io_executor.hpp:28
The is_executor trait detects whether a type T satisfies the execution::executor concept.
Definition: executor.hpp:109