Skip to content

Explain repeat_until completion_signatures #1932

@BartolomeyKant

Description

@BartolomeyKant

I'm trying to use repeat_until and assign final sender to any_sender. So I need to specify sender's completion_signatures properly. But using repeat_until generates a mess in completion_signature.

I made a short example of that I want to achieve. https://godbolt.org/z/jKMMbzvYf

    using namespace stdexec;
    using namespace experimental::execution;

    using expected = completion_signatures<set_value_t(bool), set_error_t(int)>;

    auto s = just(true) | then([](bool i) { return !i; }) |
             let_error([](auto&&...) noexcept { return just_error(1); });

    using sc = decltype(get_completion_signatures<decltype(s)>());
    static_assert(std::is_same_v<expected, sc>);

    auto s2 = just(true) | then([](bool i) { return !i; }) | repeat_until() |
              let_error([](auto&&...) noexcept { return just_error(1); });

    using s2c = decltype(get_completion_signatures<decltype(s2)>());
    static_assert(std::is_same_v<expected, s2c>);  // compilation error
    //<source>:21:19: error: static assertion failed due to requirement
    // 'std::is_same_v<stdexec::completion_signatures<stdexec::set_value_t
    // (bool), stdexec::set_error_t (int)>,
    //                       stdexec::_ERROR_<stdexec::dependent_sender_error,
    //                       stdexec::_WITH_SENDER_<stdexec::__basic_sender<stdexec::then_t,
    //                       (lambda at <source>:17:33),
    //                       stdexec::__basic_sender<stdexec::just_t,
    //                       stdexec::__tup::__tuple<bool>>::type>::type>>>'
    //   21 |     static_assert(std::is_same_v<expected, s2c>);
    //      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // 1 error generated.

    return 0;

In case of s using let_error converts all the error types to int, so result completion is the same as expected.

But this didn't work for s2 with repeat_until. The result completion is far more different than expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions