1
+ // src/Beman/Execution26/tests/exec-fwd-env.pass.cpp -*-C++-*-
2
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3
+
4
+ #include < Beman/Execution26/detail/forwarding_query.hpp>
5
+ #include < Beman/Execution26/execution.hpp>
6
+ #include < test/execution.hpp>
7
+ #include < concepts>
8
+
9
+ // ----------------------------------------------------------------------------
10
+
11
+ namespace
12
+ {
13
+ struct derived
14
+ : test_std::forwarding_query_t
15
+ {
16
+ };
17
+
18
+ template <bool Noexcept = true , typename Result = bool , Result Value = true >
19
+ struct static_query
20
+ {
21
+ constexpr auto query (test_std::forwarding_query_t ) noexcept (Noexcept) -> Result
22
+ {
23
+ return Value;
24
+ }
25
+ };
26
+
27
+ struct rvalue_query
28
+ {
29
+ constexpr auto query (test_std::forwarding_query_t ) && noexcept -> bool
30
+ {
31
+ return true ;
32
+ }
33
+ };
34
+
35
+ struct const_query
36
+ {
37
+ constexpr auto query (test_std::forwarding_query_t &&) noexcept -> bool = delete;
38
+ constexpr auto query (test_std::forwarding_query_t &) noexcept -> bool = delete;
39
+ constexpr auto query (test_std::forwarding_query_t const &) noexcept -> bool
40
+ {
41
+ return true ;
42
+ }
43
+ };
44
+
45
+ struct dynamic_query
46
+ {
47
+ bool value{true };
48
+ constexpr auto query (test_std::forwarding_query_t ) && noexcept -> bool
49
+ {
50
+ return value;
51
+ }
52
+ };
53
+ }
54
+
55
+ auto main (int ac, char *[]) -> int
56
+ {
57
+ static_assert (std::same_as<test_std::forwarding_query_t const ,
58
+ decltype (test_std::forwarding_query)>);
59
+
60
+ static_assert (not test_std::forwarding_query (0 ));
61
+ static_assert (test_std::forwarding_query (derived ()));
62
+ static_assert (test_std::forwarding_query (static_query<>()));
63
+ static_assert (not test_std::forwarding_query (static_query<false >()));
64
+ static_assert (not test_std::forwarding_query (static_query<true , int >()));
65
+ static_assert (not test_std::forwarding_query (static_query<true , bool , false >()));
66
+
67
+ static_assert (test_std::forwarding_query (rvalue_query ()));
68
+ rvalue_query rq{};
69
+ static_assert (not test_std::forwarding_query (rq));
70
+ rvalue_query crq{};
71
+ static_assert (not test_std::forwarding_query (crq));
72
+
73
+ static_assert (test_std::forwarding_query (const_query ()));
74
+
75
+ static_assert (test_std::forwarding_query (dynamic_query ()));
76
+ static_assert (test_std::forwarding_query (dynamic_query{true }));
77
+ static_assert (not test_std::forwarding_query (dynamic_query{false }));
78
+ assert (test_std::forwarding_query (dynamic_query{ac == 1 }));
79
+ assert (not test_std::forwarding_query (dynamic_query{ac != 1 }));
80
+ }
0 commit comments