Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions include/stdexec/__detail/__let.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,24 @@ namespace STDEXEC
using __what_t = __bad_result_sender_t<__sndr2_t, _LetTag, __env2_t<_Child, _Env>...>;
return STDEXEC::__throw_compile_time_error(__what_t());
}
else if constexpr (__nothrow_decay_copyable<_Args...>
&& __nothrow_invocable<_Fun, __decay_t<_Args>&...>
&& sizeof...(_Env) == 0)
{
auto __completions =
STDEXEC::get_completion_signatures<__sndr2_t, __env2_t<_Child, _Env>...>();
STDEXEC_IF_OK(__completions)
{
if constexpr (__completions.template __contains<__eptr_sig_t>())
{
return __completions;
}
else
{
return STDEXEC::__throw_dependent_sender_error<__sndr2_t>();
}
}
}
else if constexpr (__nothrow_decay_copyable<_Args...>
&& __nothrow_invocable<_Fun, __decay_t<_Args>&...>
&& (__nothrow_connectable<__sndr2_t, __rcvr2_t<_Child, _Env>>
Expand Down
10 changes: 10 additions & 0 deletions test/stdexec/algos/adaptors/test_let_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ namespace
STDEXEC::sync_wait(std::move(snd));
}

TEST_CASE("let_error can be followed by upon_error", "[adaptors][let_error]")
{
auto snd = ex::just_error(2)
| ex::let_error([](int n) noexcept { return ex::just_error(n * 10); })
| ex::upon_error([](int n) noexcept { return n + 3; });
auto opt = ex::sync_wait(std::move(snd));
REQUIRE(opt.has_value());
CHECK(std::get<0>(*opt) == 23);
}

#if !STDEXEC_NO_STDCPP_EXCEPTIONS()
TEST_CASE("let_error can be used to produce values (error to value)", "[adaptors][let_error]")
{
Expand Down
Loading