|
4 | 4 | #ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_BULK |
5 | 5 | #define INCLUDED_BEMAN_EXECUTION_DETAIL_BULK |
6 | 6 |
|
7 | | -#include "beman/execution/detail/error_types_of_t.hpp" |
8 | | -#include "beman/execution/detail/meta_combine.hpp" |
9 | | -#include "beman/execution/detail/meta_unique.hpp" |
10 | | -#include "beman/execution/detail/set_stopped.hpp" |
11 | | -#include "beman/execution/detail/value_types_of_t.hpp" |
| 7 | +#include "beman/execution/detail/callable.hpp" |
| 8 | +#include "beman/execution/detail/get_completion_signatures.hpp" |
| 9 | +#include "beman/execution/detail/nothrow_callable.hpp" |
12 | 10 | #include <beman/execution/detail/basic_sender.hpp> |
13 | 11 | #include <beman/execution/detail/completion_signatures.hpp> |
14 | 12 | #include <beman/execution/detail/completion_signatures_for.hpp> |
@@ -80,37 +78,56 @@ struct impls_for<bulk_t> : ::beman::execution::detail::default_impls { |
80 | 78 | }; |
81 | 79 | }; |
82 | 80 |
|
83 | | -template <class Shape, class f, class Sender, class Env> |
84 | | -struct completion_signatures_for_impl< |
85 | | - ::beman::execution::detail:: |
86 | | - basic_sender<::beman::execution::detail::bulk_t, ::beman::execution::detail::product_type<Shape, f>, Sender>, |
87 | | - Env> { |
| 81 | +template <typename T> |
| 82 | +struct print_type; |
| 83 | + |
| 84 | +// Specialization to trigger a compile-time error and print the type |
| 85 | +template <typename T> |
| 86 | +struct print_type { |
| 87 | + static_assert(sizeof(T) == 0, "Debugging type..."); |
| 88 | +}; |
| 89 | + |
| 90 | +/*template <typename, typename, typename, typename,typename> |
| 91 | +struct fixed_completions_helper; |
| 92 | +template <typename F, typename Shape,typename Sender,typename Env, typename... Args> |
| 93 | +struct fixed_completions_helper<F, Shape,Sender, Env, completion_signatures<Args...>> { |
| 94 | + using completions = ::beman::execution::value_types_of_t<Sender,Env>; |
| 95 | + static_assert(std::is_invocable_v<F, completions>,"Error: The function is not callable with the given arguments."); |
| 96 | + using type = std::conditional_t<::beman::execution::detail::nothrow_callable<F, Args ...>, |
| 97 | + completion_signatures<Args...>, |
| 98 | + completion_signatures<Args..., set_error_t(std::exception_ptr)>>; |
| 99 | +}; |
88 | 100 |
|
89 | | - // Creates a completion signature for set_value_t |
90 | | - template <class... Args> |
91 | | - using make_value_completions = |
92 | | - ::beman::execution::completion_signatures<::beman::execution::set_value_t(const std::decay_t<Args>&...)>; |
| 101 | +template <typename F, typename Shape, typename Sender , typename Env, typename completions> |
| 102 | +using fixed_completions = typename fixed_completions_helper<F, Shape, Sender , Env, completions>::type;*/ |
93 | 103 |
|
94 | | - // Creates a completion signature for set_error_t |
95 | | - template <class... Args> |
96 | | - using make_error_completions = |
97 | | - ::beman::execution::completion_signatures<::beman::execution::set_error_t(const std::decay_t<Args>&)...>; |
98 | 104 |
|
99 | | - // Retrieves the value completion signatures from the Sender using Env, |
100 | | - // then applies make_value_completions to format them and merges all signatures. |
101 | | - using value_completions = ::beman::execution:: |
102 | | - value_types_of_t<Sender, Env, make_value_completions, ::beman::execution::detail::meta::combine>; |
103 | 105 |
|
104 | | - // Retrieves the error completion signatures from the Sender using Env, |
105 | | - // then applies make_error_completions to format them. |
106 | | - using error_completions = ::beman::execution::error_types_of_t<Sender, Env, make_error_completions>; |
107 | 106 |
|
108 | | - using fixed_completions = |
109 | | - ::beman::execution::completion_signatures<::beman::execution::set_stopped_t(), |
110 | | - ::beman::execution::set_error_t(std::exception_ptr)>; |
| 107 | +template <typename, typename, typename> |
| 108 | +struct fixed_completions_helper; |
| 109 | + |
| 110 | +template <typename F, typename Shape, typename... Args> |
| 111 | +struct fixed_completions_helper<F, Shape, completion_signatures<Args...>> { |
| 112 | + //static_assert(std::is_invocable_v<F, Shape, Args...>,"Error: The function is not callable with the given arguments."); |
| 113 | + using type = std::conditional_t<::beman::execution::detail::nothrow_callable<F, Args ...>, |
| 114 | + completion_signatures<Args...>, |
| 115 | + completion_signatures<Args..., set_error_t(std::exception_ptr)>>; |
| 116 | +}; |
| 117 | + |
| 118 | +template <typename F, typename Shape, typename Completions> |
| 119 | +using fixed_completions = typename fixed_completions_helper<F, Shape, Completions>::type; |
| 120 | + |
| 121 | +template <class Shape, class F, class Sender, class Env> |
| 122 | +struct completion_signatures_for_impl< |
| 123 | + ::beman::execution::detail:: |
| 124 | + basic_sender<::beman::execution::detail::bulk_t, ::beman::execution::detail::product_type<Shape, F>, Sender>, |
| 125 | + Env> { |
| 126 | + |
111 | 127 |
|
112 | | - using type = ::beman::execution::detail::meta::unique< |
113 | | - ::beman::execution::detail::meta::combine<fixed_completions, value_completions, error_completions>>; |
| 128 | + using completions = decltype(get_completion_signatures(std::declval<Sender>(), std::declval<Env>())); |
| 129 | + using type = fixed_completions<F, Shape, completions>; |
| 130 | + //print_type<type> debug; |
114 | 131 | }; |
115 | 132 |
|
116 | 133 | } // namespace beman::execution::detail |
|
0 commit comments