1010#include < beman/execution26/detail/basic_state.hpp>
1111#include < beman/execution26/detail/product_type.hpp>
1212#include < beman/execution26/detail/sender_decompose.hpp>
13+ #include < beman/execution26/detail/forward_like.hpp>
1314#include < cstddef>
1415#include < tuple>
1516#include < utility>
@@ -25,24 +26,55 @@ namespace beman::execution26::detail {
2526 * \internal
2627 */
2728struct connect_all_t {
29+ private:
30+ template <typename Fun, typename Tuple, ::std::size_t ... I>
31+ static auto apply_with_index_helper (::std::index_sequence<I...> seq, Fun&& fun, Tuple&& tuple) noexcept (noexcept (
32+ ::std::forward<Fun>(fun)(seq, ::beman::execution26::detail::forward_like<Tuple>(::std::get<I>(tuple))...)))
33+ -> decltype(auto ) {
34+ return ::std::forward<Fun>(fun)(seq,
35+ ::beman::execution26::detail::forward_like<Tuple>(::std::get<I>(tuple))...);
36+ }
37+ template <typename Fun, typename Tuple>
38+ static auto apply_with_index (Fun&& fun, Tuple&& tuple) noexcept (
39+ noexcept (apply_with_index_helper(::std::make_index_sequence<::std::tuple_size_v<::std::decay_t <Tuple>>>{},
40+ ::std::forward<Fun>(fun),
41+ ::std::forward<Tuple>(tuple)))) -> decltype(auto ) {
42+ return apply_with_index_helper (::std::make_index_sequence<::std::tuple_size_v<::std::decay_t <Tuple>>>{},
43+ ::std::forward<Fun>(fun),
44+ ::std::forward<Tuple>(tuple));
45+ }
46+
47+ template <typename Sender, typename Receiver>
48+ struct connect_helper {
49+ ::beman::execution26::detail::basic_state<Sender, Receiver>* op;
50+
51+ template <::std::size_t ... J, typename ... C>
52+ auto operator ()(::std::index_sequence<J...>, C&&... c) noexcept (
53+ (noexcept (::beman::execution26::connect(
54+ ::beman::execution26::detail::forward_like<Sender>(c),
55+ ::beman::execution26::detail::basic_receiver<Sender, Receiver, ::std::integral_constant<::size_t, J>>{
56+ this ->op })) &&
57+ ... && true )) -> decltype (auto ) {
58+ return ::beman::execution26::detail::product_type{::beman::execution26::connect (
59+ ::beman::execution26::detail::forward_like<Sender>(c),
60+ ::beman::execution26::detail::basic_receiver<Sender, Receiver, ::std::integral_constant<::size_t , J>>{
61+ this ->op })...};
62+ }
63+ };
64+
2865 static auto use (auto &&...) {}
66+
67+ public:
2968 // -dk:TODO is the S parameter deviating from the spec?
3069 template <typename Sender, typename S, typename Receiver, ::std::size_t ... I>
3170 auto operator ()(::beman::execution26::detail::basic_state<Sender, Receiver>* op,
3271 S&& sender,
33- ::std::index_sequence<I...>) const noexcept (true /* -dk:TODO*/ ) {
34- auto data{::beman::execution26::detail::get_sender_data (::std::forward<S>(sender))};
35- return ::std::apply (
36- [&op](auto &&... c) {
37- return [&op]<::std::size_t ... J>(::std::index_sequence<J...>, auto &&... c) {
38- use (op);
39- return ::beman::execution26::detail::product_type{::beman::execution26::connect (
40- ::beman::execution26::detail::forward_like<Sender>(c),
41- ::beman::execution26::detail::
42- basic_receiver<Sender, Receiver, ::std::integral_constant<::size_t , J>>{op})...};
43- }(::std::make_index_sequence<::std::tuple_size_v<::std::decay_t <decltype (data.children )>>>{}, c...);
44- },
45- data.children );
72+ ::std::index_sequence<I...>) const
73+ noexcept (noexcept (apply_with_index(
74+ connect_helper<Sender, Receiver>{op},
75+ ::beman::execution26::detail::get_sender_data (::std::forward<S>(sender)).children))) -> decltype(auto ) {
76+ return apply_with_index (connect_helper<Sender, Receiver>{op},
77+ ::beman::execution26::detail::get_sender_data (::std::forward<S>(sender)).children);
4678 }
4779};
4880
0 commit comments