Skip to content
Open
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
19 changes: 17 additions & 2 deletions include/exec/repeat_until.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,28 @@ namespace experimental::execution
__delete_set_value_t>,
__mbind_front_q<__values_t, _Child>::template __f>;

struct _FAILED_TO_FORM_COMPLETION_SIGNATURES
{};

struct __repeat_until_impl : __sexpr_defaults
{
template <class _Sender, class... _Env>
static consteval auto __get_completion_signatures()
{
// TODO: port this to use constant evaluation
return __completions_t<__child_of<_Sender>, _Env...>{};
using __child_t = __child_of<_Sender>;
if constexpr (::STDEXEC::__minvocable_q<__completions_t, __child_t, _Env...>)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo, better would be to change __completions_t to always be well-formed and return descriptive errors. best would be to rewrite this function to use consteval instead of TMP.

{
return __completions_t<__child_t, _Env...>{};
}
else if constexpr (sizeof...(_Env) == 0)
{
return STDEXEC::__dependent_sender<_Sender>();
}
else
{
return ::STDEXEC::__throw_compile_time_error<_FAILED_TO_FORM_COMPLETION_SIGNATURES,
::STDEXEC::_WITH_PRETTY_SENDER_<_Sender>>();
}
};

static constexpr auto __connect =
Expand Down
19 changes: 19 additions & 0 deletions test/exec/test_repeat_until.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
#include <catch2/catch.hpp>

#include <concepts>
#include <cstddef>
#include <limits>
#include <memory>
#include <stdexcept>
#include <type_traits>
#include <utility>

namespace ex = STDEXEC;
Expand Down Expand Up @@ -407,4 +409,21 @@ namespace {
"Missing added set_error_t(std::exception_ptr)");
}
}

TEST_CASE("repeat_until works with a dependent sender", "[adaptors][repeat_until]")
{
std::size_t invoked = 0;
auto snd = exec::repeat_until(ex::read_env(ex::get_stop_token)
| ex::then(
[&](auto token) noexcept
{
++invoked;
return std::is_same_v<ex::never_stop_token, decltype(token)>;
}));
static_assert(ex::dependent_sender<decltype(snd)>);
auto op = ex::connect(std::move(snd), expect_void_receiver{});
CHECK(!invoked);
ex::start(op);
CHECK(invoked == 1);
}
} // namespace
Loading