Let split-receiver denote
the following exposition-only class template:
namespace std::execution {
template<class Sndr>
struct split-receiver {
using receiver_concept = receiver_t;
template<class Tag, class... Args>
void complete(Tag, Args&&... args) noexcept {
using tuple_t = decayed-tuple<Tag, Args...>;
try {
sh_state->result.template emplace<tuple_t>(Tag(), std::forward<Args>(args)...);
} catch (...) {
using tuple_t = tuple<set_error_t, exception_ptr>;
sh_state->result.template emplace<tuple_t>(set_error, current_exception());
}
sh_state->notify();
}
template<class... Args>
void set_value(Args&&... args) && noexcept {
complete(execution::set_value, std::forward<Args>(args)...);
}
template<class Error>
void set_error(Error&& err) && noexcept {
complete(execution::set_error, std::forward<Error>(err));
}
void set_stopped() && noexcept {
complete(execution::set_stopped);
}
struct env {
shared-state<Sndr>* sh-state;
inplace_stop_token query(get_stop_token_t) const noexcept {
return sh-state->stop_src.get_token();
}
};
env get_env() const noexcept {
return env{sh_state};
}
shared-state<Sndr>* sh_state;
};
}