Skip to content

Commit d6a6c17

Browse files
authored
Merge pull request #36 from beman-project/fix-read_env-signatures
fixed completion signatures for read_env and noexcept for get_env
2 parents 7453078 + 702b1a7 commit d6a6c17

File tree

4 files changed

+38
-8
lines changed

4 files changed

+38
-8
lines changed

include/beman/execution26/detail/get_env.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace beman::execution26
2020
not requires(Object&& object) { ::std::as_const(object).get_env(); }
2121
|| ::beman::execution26::detail::queryable<std::remove_cvref_t<decltype(::std::declval<::std::remove_cvref_t<Object> const&>().get_env())>>
2222
)
23-
auto operator()(Object&& object) const -> decltype(auto)
23+
auto operator()(Object&& object) const noexcept -> decltype(auto)
2424
{
2525
if constexpr (requires{ ::std::as_const(object).get_env(); })
2626
{

include/beman/execution26/detail/read_env.hpp

+15-5
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,22 @@ namespace beman::execution26::detail
6464
Env
6565
>
6666
{
67-
using type = ::beman::execution26::completion_signatures<
68-
::beman::execution26::set_value_t(
67+
using set_value_type = ::beman::execution26::set_value_t(
6968
decltype(::std::declval<Query>()(::std::as_const(::std::declval<Env>())))
70-
),
71-
::beman::execution26::set_error_t(::std::exception_ptr)
72-
>;
69+
);
70+
using set_error_type = ::beman::execution26::set_error_t(
71+
::std::exception_ptr
72+
);
73+
using type = ::std::conditional_t<
74+
noexcept(::std::declval<Query>()(::std::declval<Env const&>())),
75+
::beman::execution26::completion_signatures<
76+
set_value_type
77+
>,
78+
::beman::execution26::completion_signatures<
79+
set_value_type,
80+
set_error_type
81+
>
82+
>;
7383
};
7484
}
7585

include/test/execution.hpp

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#define INCLUDED_TEST_EXECUTION
66

77
#include <beman/execution26/stop_token.hpp>
8+
#include <concepts>
89
#include <cassert>
910
#include <cstddef>
1011

@@ -16,6 +17,11 @@ namespace test_detail = ::beman::execution26::detail;
1617
namespace test
1718
{
1819
template <typename> auto type_exists() {}
20+
template <typename T0, typename T1>
21+
auto check_type(T1&&)
22+
{
23+
static_assert(std::same_as<T0, T1>);
24+
}
1925

2026
auto use(auto&&...) noexcept -> void {}
2127
}

src/beman/execution26/tests/exec-read-env.pass.cpp

+16-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
33

44
#include <beman/execution26/detail/read_env.hpp>
5+
#include <beman/execution26/detail/common.hpp>
56
#include <beman/execution26/detail/get_domain.hpp>
67
#include <beman/execution26/detail/sender.hpp>
78
#include <beman/execution26/detail/sender_in.hpp>
89
#include <beman/execution26/detail/receiver.hpp>
910
#include <beman/execution26/detail/connect.hpp>
1011
#include <beman/execution26/detail/start.hpp>
12+
#include <beman/execution26/detail/get_stop_token.hpp>
1113
#include <test/execution.hpp>
1214
#include <concepts>
1315

@@ -59,8 +61,8 @@ namespace
5961
static_assert(test_std::sender_in<decltype(sender), env>);
6062
static_assert(std::same_as<
6163
test_std::completion_signatures<
62-
test_std::set_value_t(domain),
63-
test_std::set_error_t(std::exception_ptr)
64+
test_std::set_value_t(domain)
65+
//-dk:TODO verify , test_std::set_error_t(std::exception_ptr)
6466
>,
6567
decltype(test_std::get_completion_signatures(sender, env{}))
6668
>);
@@ -75,10 +77,22 @@ namespace
7577
test_std::start(op);
7678
assert(called);
7779
}
80+
81+
auto test_read_env_completions() -> void
82+
{
83+
auto r{test_std::read_env(test_std::get_stop_token)};
84+
test::check_type<
85+
test_std::completion_signatures<
86+
test_std::set_value_t(test_std::never_stop_token)
87+
>
88+
>(test_std::get_completion_signatures(r, test_std::empty_env{}));
89+
test_std::detail::use(r);
90+
}
7891
}
7992

8093
auto main() -> int
8194
{
8295
static_assert(std::same_as<test_std::read_env_t const, decltype(test_std::read_env)>);
8396
test_read_env();
97+
test_read_env_completions();
8498
}

0 commit comments

Comments
 (0)