Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions include/exec/just_from.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,16 @@ namespace experimental::execution

template <class Rcvr>
STDEXEC_ATTRIBUTE(host, device)
auto submit(Rcvr rcvr) && noexcept -> void
auto submit(Rcvr rcvr) && noexcept(STDEXEC::__nothrow_decay_copyable<Rcvr, Fn>) -> void

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

receivers are now required to be nothrow move constructible, so this check is unnecessary.

Suggested change
auto submit(Rcvr rcvr) && noexcept(STDEXEC::__nothrow_decay_copyable<Rcvr, Fn>) -> void
auto submit(Rcvr rcvr) && noexcept(STDEXEC::__nothrow_decay_copyable<Fn>) -> void

{
auto op = static_cast<_sndr_base&&>(*this).connect(static_cast<Rcvr&&>(rcvr));
STDEXEC::start(op);
}

template <class Rcvr>
STDEXEC_ATTRIBUTE(host, device)
auto submit(Rcvr rcvr) const & noexcept -> void
auto submit(Rcvr rcvr) const & noexcept(STDEXEC::__nothrow_decay_copyable<Rcvr, Fn const &>)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
auto submit(Rcvr rcvr) const & noexcept(STDEXEC::__nothrow_decay_copyable<Rcvr, Fn const &>)
auto submit(Rcvr rcvr) const & noexcept(STDEXEC::__nothrow_decay_copyable<Fn const &>)

-> void
{
auto op = this->connect(static_cast<Rcvr&&>(rcvr));
STDEXEC::start(op);
Expand Down
36 changes: 29 additions & 7 deletions test/exec/test_just_from.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#include "exec/just_from.hpp"
#include "test_common/receivers.hpp"
#include "test_common/tuple.hpp"
#include "test_common/type_helpers.hpp"

Expand All @@ -26,13 +27,19 @@ namespace

struct throwing_move_callable
{
throwing_move_callable() = default;
throwing_move_callable(throwing_move_callable const &) noexcept = default;
throwing_move_callable(throwing_move_callable &&other) noexcept(false)
explicit throwing_move_callable(bool& should_throw) noexcept
: should_throw_(&should_throw)
{}

throwing_move_callable(throwing_move_callable const &other) noexcept
: should_throw_(other.should_throw_)
{}

throwing_move_callable(throwing_move_callable&& other) noexcept(false)
: should_throw_(other.should_throw_)
{
#if !STDEXEC_NO_STDCPP_EXCEPTIONS()
if (should_throw_)
if (*should_throw_)
{
throw 42;
}
Expand All @@ -45,7 +52,7 @@ namespace
return sink();
}

bool should_throw_{false};
bool* should_throw_;
};

TEST_CASE("just_from is a sender", "[just_from]")
Expand Down Expand Up @@ -94,15 +101,30 @@ namespace
};
STATIC_REQUIRE(noexcept(exec::just_from(nothrow_fn)));

throwing_move_callable fn;
bool should_throw = false;
throwing_move_callable fn{should_throw};
STATIC_REQUIRE_FALSE(noexcept(exec::just_from(fn)));

#if !STDEXEC_NO_STDCPP_EXCEPTIONS()
fn.should_throw_ = true;
should_throw = true;
CHECK_THROWS_AS(exec::just_from(fn), int);
#endif
}

TEST_CASE("just_from submit is conditionally noexcept", "[just_from]")
{
bool should_throw = false;
auto s = exec::just_from(throwing_move_callable{should_throw});

STATIC_REQUIRE_FALSE(noexcept(static_cast<decltype(s)&&>(s).submit(empty_recv::recv0{})));
STATIC_REQUIRE(noexcept(s.submit(empty_recv::recv0{})));

#if !STDEXEC_NO_STDCPP_EXCEPTIONS()
should_throw = true;
CHECK_THROWS_AS(static_cast<decltype(s)&&>(s).submit(empty_recv::recv0{}), int);
#endif
}

TEST_CASE("just_from with multiple completions", "[just_from]")
{
auto fn = [](auto sink) noexcept
Expand Down
Loading