Skip to content

Commit 9bce1ba

Browse files
committed
fun_receiver: set_value(Ts...) => set_value(Ts&&...)
Sending completion signals to receivers must not throw, including set_value. This is enforced as can be seen in this error which was observed before the application of this commit: /stdexec/__detail/__receivers.hpp:47:11: error: static assertion failed: set_value member functions must be noexcept 47 | noexcept(static_cast<_Receiver&&>(__rcvr).set_value(static_cast<_As&&>(__as)...)), | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ An obvious consequence of the above is that the set_value member function(s) of a receiver must be marked noexcept. However the evaluation of a function itself is not the only thing that can throw when invoking a function: The population of the parameters thereto may emit an exception. For example a function may accept parameters by value thereby requiring the caller to copy or move the arguments thereto. Since, as alluded to above, the parameters are populated in the context of the caller the only thing a function can do to prevent such exceptions is to accept its parameters by reference (thereby obviating the need to move construct arguments thereto). Previously the test helper fun_receiver did not do this leading to the error provided above. Updated fun_receiver::set_value to accept parameters by forwarding reference thereby allowing it to accept parameters whose move constructors are not noexcept.
1 parent 3a155e1 commit 9bce1ba

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

test/test_common/receivers.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ namespace {
487487
F f_;
488488

489489
template <class... Ts>
490-
void set_value(Ts... vals) noexcept {
490+
void set_value(Ts&&... vals) noexcept {
491491
STDEXEC_TRY {
492492
std::move(f_)(static_cast<Ts&&>(vals)...);
493493
}

0 commit comments

Comments
 (0)