Skip to content

Commit

Permalink
Merge 46e53ba into d43b7e1
Browse files Browse the repository at this point in the history
  • Loading branch information
aurianer authored Oct 6, 2022
2 parents d43b7e1 + 46e53ba commit cf7b2a8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,19 @@ namespace pika::let_value_detail {
predecessor_sender;
PIKA_NO_UNIQUE_ADDRESS std::decay_t<F> f;

template <typename Tuple>
struct predecessor_value_types_helper
{
using type = pika::util::detail::transform_t<Tuple, std::decay>;
};

// Type of the potential values returned from the predecessor sender
template <template <typename...> class Tuple,
template <typename...> class Variant>
using predecessor_value_types =
typename pika::execution::experimental::sender_traits<std::decay_t<
PredecessorSender>>::template value_types<Tuple, Variant>;
using predecessor_value_types = pika::util::detail::transform_t<
typename pika::execution::experimental::sender_traits<
PredecessorSender>::template value_types<Tuple, Variant>,
predecessor_value_types_helper>;

template <typename Tuple>
struct successor_sender_types_helper;
Expand Down Expand Up @@ -268,9 +275,9 @@ namespace pika::let_value_detail {
{
pika::detail::try_catch_exception_ptr(
[&]() {
op_state.predecessor_ts
.template emplace<std::tuple<Ts...>>(
PIKA_FORWARD(Ts, ts)...);
op_state.predecessor_ts.template emplace<
std::tuple<std::decay_t<Ts>...>>(
PIKA_FORWARD(Ts, ts)...);
pika::detail::visit(
set_value_visitor{PIKA_MOVE(receiver),
PIKA_MOVE(f), op_state},
Expand All @@ -287,7 +294,8 @@ namespace pika::let_value_detail {
pika::execution::experimental::set_value_t,
let_value_predecessor_receiver&& r, Ts&&... ts) noexcept
-> decltype(std::declval<predecessor_ts_type>()
.template emplace<std::tuple<Ts...>>(
.template emplace<
std::tuple<std::decay_t<Ts>...>>(
PIKA_FORWARD(Ts, ts)...),
void())
{
Expand Down
18 changes: 18 additions & 0 deletions libs/pika/execution/tests/unit/algorithm_let_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,24 @@ int main()
PIKA_TEST(let_value_callback_called);
}

{
std::atomic<bool> set_value_called{false};
std::atomic<bool> let_value_callback_called{false};
int x = 42;
auto s1 = const_reference_sender<int>{x};
auto s2 = ex::let_value(std::move(s1), [&](auto& x) {
PIKA_TEST_EQ(x, 42);
let_value_callback_called = true;
return ex::just(x);
});
auto f = [](int x) { PIKA_TEST_EQ(x, 42); };
auto r = callback_receiver<decltype(f)>{f, set_value_called};
auto os = ex::connect(std::move(s2), std::move(r));
ex::start(os);
PIKA_TEST(set_value_called);
PIKA_TEST(let_value_callback_called);
}

// operator| overload
{
std::atomic<bool> set_value_called{false};
Expand Down

0 comments on commit cf7b2a8

Please sign in to comment.