kokkos-execution 0.0.1
Loading...
Searching...
No Matches
check_rcvr_env_queryable_with.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_EXECUTION_TESTS_UTILS_CHECK_RCVR_ENV_QUERYABLE_WITH_HPP
2#define KOKKOS_EXECUTION_TESTS_UTILS_CHECK_RCVR_ENV_QUERYABLE_WITH_HPP
3
5
9
11
17
18namespace Tests::Utils {
19
20template <bool IsQueryable, stdexec::sender Sndr, typename... Queries>
22
23template <bool IsQueryable, typename... Queries>
25 [[nodiscard]]
26 constexpr auto operator()() const noexcept {
27 return stdexec::__closure(*this);
28 }
29
30 template <stdexec::sender Sndr>
31 [[nodiscard]]
32 constexpr auto operator()(Sndr&& sndr) const {
33 return CheckRcvrEnvQueryableWithSender<IsQueryable, Sndr, Queries...>{std::forward<Sndr>(sndr)};
34 }
35};
36
37template <bool IsQueryable, stdexec::sender Sndr, typename... Queries>
39 using sender_concept = stdexec::sender_t;
40
41 Sndr sndr; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members)
42
44
45 template <stdexec::receiver Rcvr>
46 constexpr auto connect(Rcvr rcvr) && noexcept(stdexec::__nothrow_connectable<Sndr&&, Rcvr&&>) {
47 static_assert(check_rcvr_env<Rcvr>());
48 return stdexec::connect(std::forward<Sndr>(sndr), std::move(rcvr));
49 }
50
51 template <stdexec::receiver Rcvr>
52 constexpr auto connect(Rcvr rcvr) const & noexcept(stdexec::__nothrow_connectable<const Sndr&, Rcvr&&>) {
53 static_assert(check_rcvr_env<Rcvr>());
54 return stdexec::connect(sndr, std::move(rcvr));
55 }
56
57 template <stdexec::receiver Rcvr>
58 static consteval bool check_rcvr_env() {
59 if constexpr (IsQueryable) {
60 static_assert(
61 (stdexec::__queryable_with<stdexec::env_of_t<Rcvr>, Queries> && ...),
62 "The receiver environment is not queryable with at least one query from the given set of queries.");
63 } else {
64 static_assert(
65 ((!stdexec::__queryable_with<stdexec::env_of_t<Rcvr>, Queries>) && ...),
66 "The receiver environment is queryable with at least one query from the given set of queries.");
67 }
68 return true;
69 }
70
72};
73
74template <typename... Queries>
76
77template <typename... Queries>
79
80} // namespace Tests::Utils
81
82#endif // KOKKOS_EXECUTION_TESTS_UTILS_CHECK_RCVR_ENV_QUERYABLE_WITH_HPP
#define KOKKOS_EXECUTION_IMPL_FORWARDING_ATTRIBUTES_GET_ENV(_type_, _obj_)
#define KOKKOS_EXECUTION_COMPL_SIGS_KEEP(_sndr_type_)
constexpr check_rcvr_env_queryable_with_t< false, Queries... > check_rcvr_env_not_queryable_with
constexpr check_rcvr_env_queryable_with_t< true, Queries... > check_rcvr_env_queryable_with
constexpr auto connect(Rcvr rcvr) const &noexcept(stdexec::__nothrow_connectable< const Sndr &, Rcvr && >)
constexpr auto connect(Rcvr rcvr) &&noexcept(stdexec::__nothrow_connectable< Sndr &&, Rcvr && >)