Skip to content

Commit d81c734

Browse files
authored
deprecate stdexec::transform_completion_signatures[_of] (#1915)
* deprecate `stdexec::transform_completion_signatures[_of]` and point folks to `exec::transform_completion_signatures` instead
1 parent b70c10b commit d81c734

51 files changed

Lines changed: 502 additions & 328 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/algorithms/retry.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ struct _retry_sender
134134
using _value = stdexec::completion_signatures<stdexec::set_value_t(Ts...)>;
135135

136136
template <class Self, class... Env>
137-
static consteval auto get_completion_signatures() -> stdexec::transform_completion_signatures<
137+
static consteval auto get_completion_signatures() -> stdexec::__transform_completion_signatures_t<
138138
stdexec::completion_signatures_of_t<S&, Env...>,
139139
stdexec::completion_signatures<stdexec::set_error_t(std::exception_ptr)>,
140140
_value,

examples/algorithms/then.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct _then_sender
7070
stdexec::completion_signatures<stdexec::set_value_t(std::invoke_result_t<F, Args...>)>;
7171

7272
template <class... Env>
73-
using _completions_t = stdexec::transform_completion_signatures<
73+
using _completions_t = stdexec::__transform_completion_signatures_t<
7474
stdexec::completion_signatures_of_t<S, Env...>,
7575
stdexec::completion_signatures<stdexec::set_error_t(std::exception_ptr)>,
7676
_set_value_t>;

include/exec/asio/use_sender.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ namespace experimental::execution::asio
166166

167167
template <typename Signatures>
168168
using completion_signatures =
169-
::STDEXEC::transform_completion_signatures<Signatures,
170-
::STDEXEC::completion_signatures<>,
171-
transform_set_value_t>;
169+
::STDEXEC::__transform_completion_signatures_t<Signatures,
170+
::STDEXEC::completion_signatures<>,
171+
transform_set_value_t>;
172172

173173
template <typename Sender>
174174
struct sender

include/exec/async_scope.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ namespace experimental::execution
444444
using __decay_error_t = completion_signatures<set_error_t(__decay_t<_Ty>)>;
445445

446446
template <class _Sender, class _Env>
447-
using __future_completions_t = transform_completion_signatures_of<
447+
using __future_completions_t = __transform_completion_signatures_of_t<
448448
_Sender,
449449
__env_t<_Env>,
450450
completion_signatures<set_stopped_t(), set_error_t(std::exception_ptr)>,

include/exec/completion_signatures.hpp

Lines changed: 133 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,25 @@ namespace experimental::execution
5858
//! by combining explicitly provided signature types with those deduced from pointer
5959
//! arguments.
6060
//!
61-
//! @tparam ExplicitSigs Explicitly specified completion signature types.
62-
//! @tparam DeducedSigs Completion signature types to be deduced from the function arguments.
63-
//! @param unnamed Pointer arguments (unused) used for type deduction of DeducedSigs.
61+
//! \tparam ExplicitSigs Explicitly specified completion signature types. Must be a pack
62+
//! of function types, the returns types of which must be one of
63+
//! \c set_value_t, \c set_error_t, or \c set_stopped_t.
64+
//! \tparam DeducedSigs Completion signature types to be deduced from the function
65+
//! arguments.
66+
//! \param unnamed Pointer arguments (unused) for type deduction of
67+
//! \c DeducedSigs. Must be a pack of function pointer types, the
68+
//! returns types of which must be one of \c set_value_t,
69+
//! \c set_error_t, or \c set_stopped_t.
6470
//!
65-
//! @return An instance of `STDEXEC::completion_signatures` containing the combined
71+
//! \return An instance of \c STDEXEC::completion_signatures containing the combined
6672
//! signatures.
6773
//!
68-
//! @note This is a `consteval` function, meaning it is only callable in constant evaluation
69-
//! contexts (compile-time). It always returns a default-constructed instance of the result
70-
//! type.
74+
//! \note This is a \c consteval function, meaning it is only callable in constant
75+
//! evaluation contexts (compile-time). It always returns a default-constructed
76+
//! instance of the result type.
7177
//!
72-
//! @note The function uses pointer arguments for type deduction without requiring actual object
73-
//! instances.
78+
//! \note The function uses pointer arguments for type deduction without requiring
79+
//! actual object instances.
7480
template <class... ExplicitSigs, class... DeducedSigs>
7581
[[nodiscard]]
7682
consteval auto make_completion_signatures(DeducedSigs*...) noexcept
@@ -95,33 +101,134 @@ namespace experimental::execution
95101

96102
//////////////////////////////////////////////////////////////////////////////////////////////////
97103
// transform_completion_signatures
104+
98105
template <class _SetTag>
99106
using keep_completion = STDEXEC::__keep_completion<_SetTag>;
100107

101108
using ignore_completion = STDEXEC::__ignore_completion;
102109

103-
template <class _SetTag, class _Fn, class... _AlgoTag>
104-
using transform_arguments = STDEXEC::__transform_arguments<_SetTag, _Fn, _AlgoTag...>;
110+
template <class _SetTag, template <class> class _Fn, class... _AlgoTag>
111+
using transform_arguments =
112+
STDEXEC::__transform_arguments<_SetTag, STDEXEC::__q1<_Fn>, _AlgoTag...>;
105113

106114
template <class _SetTag, class... _AlgoTag>
107115
using decay_arguments = STDEXEC::__decay_arguments<_SetTag, _AlgoTag...>;
108116

109-
template <class _Completions,
110-
class _ValueFn = keep_completion<STDEXEC::set_value_t>,
111-
class _ErrorFn = keep_completion<STDEXEC::set_error_t>,
112-
class _StoppedFn = keep_completion<STDEXEC::set_stopped_t>,
113-
class _ExtraSigs = STDEXEC::completion_signatures<>>
114-
consteval auto transform_completion_signatures(_Completions,
115-
_ValueFn __value_fn = {},
116-
_ErrorFn __error_fn = {},
117-
_StoppedFn __stopped_fn = {},
118-
_ExtraSigs = {})
117+
//! \brief Transforms completion signatures using provided transformation functions.
118+
//!
119+
//! This consteval function transforms a set of completion signatures by applying
120+
//! custom transformation functions to value, error, and stopped completion cases.
121+
//! The result can be augmented with additional extra signatures.
122+
//!
123+
//! \tparam Completions The input completion signatures to transform. Must be a
124+
//! specialization of \c STDEXEC::completion_signatures.
125+
//! \tparam ValueFn Function object that transforms set_value_t completions.
126+
//! Defaults to keep_completion<set_value_t>.
127+
//! \tparam ErrorFn Function object that transforms set_error_t completions.
128+
//! Defaults to keep_completion<set_error_t>.
129+
//! \tparam StoppedFn Function object that transforms set_stopped_t completions.
130+
//! Defaults to keep_completion<set_stopped_t>.
131+
//! \tparam ExtraSigs Additional completion signatures to append to the result.
132+
//! Must be a specialization of \c STDEXEC::completion_signatures.
133+
//! Defaults to \c STDEXEC::completion_signatures().
134+
//!
135+
//! \param completions The input completion signatures object.
136+
//! \param value_fn Value transformation function instance.
137+
//! \param error_fn Error transformation function instance.
138+
//! \param stopped_fn Stopped transformation function instance.
139+
//! \param extra_sigs Extra signatures to append to the result.
140+
//!
141+
//! \return A transformed completion_signatures object combining the transformed
142+
//! input signatures with the extra signatures.
143+
//!
144+
//! \par Example
145+
//!
146+
//! The following example demonstrates how to use \c transform_completion_signatures
147+
//! to compute the completion signatures of the \c then sender.
148+
//!
149+
//! \code{.cpp}
150+
//! namespace ex = STDEXEC;
151+
//!
152+
//! // A helper function to transform the value types of the child sender into the value
153+
//! // types of the then sender.
154+
//! template <class Fn, class... Args>
155+
//! consteval auto _transform_values()
156+
//! {
157+
//! if constexpr (!std::invocable<Fn, Args...>)
158+
//! {
159+
//! // If Fn cannot be invoked with the given arguments, produce a compile-time
160+
//! // error.
161+
//! return exec::throw_compile_time_error<
162+
//! WHAT(FUNCTION_IS_NOT_CALLABLE_WITH_THE_GIVEN_ARGUMENTS),
163+
//! WHERE(IN_ALGORITHM, then_t),
164+
//! WITH_FUNCTION(Fn),
165+
//! WITH_ARGUMENTS(Args...)>();
166+
//! }
167+
//! else
168+
//! {
169+
//! // transform the value types of the child sender into the value types of the
170+
//! // then sender by applying Fn to them.
171+
//! using result_t = std::invoke_result_t<Fn, Args...>;
172+
//! constexpr bool is_void = std::is_void_v<result_t>;
173+
//! constexpr bool nothrow = std::is_nothrow_invocable_v<Fn, Args...>;
174+
//! if constexpr (is_void && nothrow)
175+
//! {
176+
//! return ex::completion_signatures<set_value_t()>();
177+
//! }
178+
//! else if constexpr (is_void && !nothrow)
179+
//! {
180+
//! return ex::completion_signatures<set_value_t(),
181+
//! set_error_t(std::exception_ptr)>();
182+
//! }
183+
//! else if constexpr (!is_void && nothrow)
184+
//! {
185+
//! return ex::completion_signatures<set_value_t(result_t)>();
186+
//! }
187+
//! else /* !is_void && !nothrow */
188+
//! {
189+
//! return ex::completion_signatures<set_value_t(result_t),
190+
//! set_error_t(std::exception_ptr)>();
191+
//! }
192+
//! }
193+
//! }
194+
//!
195+
//! template <class Child, class Fn>
196+
//! struct then_sender
197+
//! {
198+
//! using sender_concept = ex::sender_t;
199+
//!
200+
//! template <class Self, class... Env>
201+
//! static consteval auto get_completion_signatures()
202+
//! {
203+
//! // Compute the completion signatures of the child sender, and then transform
204+
//! // them into the completion signatures of the `then` sender.
205+
//! auto child_completions = exec::get_child_completion_signatures<Self, Child, Env...>();
206+
//! auto value_fn = []<class... Args>() { return _transform_values<Fn, Args...>(); };
207+
//!
208+
//! return exec::transform_completion_signatures(child_completions, value_fn);
209+
//! }
210+
//!
211+
//! // ...
212+
//! };
213+
//! \endcode
214+
//!
215+
//! \note This function is evaluated at compile-time (consteval).
216+
template <class Completions,
217+
class ValueFn = keep_completion<STDEXEC::set_value_t>,
218+
class ErrorFn = keep_completion<STDEXEC::set_error_t>,
219+
class StoppedFn = keep_completion<STDEXEC::set_stopped_t>,
220+
class ExtraSigs = STDEXEC::completion_signatures<>>
221+
consteval auto transform_completion_signatures(Completions,
222+
ValueFn value_fn = {},
223+
ErrorFn error_fn = {},
224+
StoppedFn stopped_fn = {},
225+
ExtraSigs = {})
119226
{
120-
return STDEXEC::__transform_completion_signatures(_Completions{},
121-
__value_fn,
122-
__error_fn,
123-
__stopped_fn,
124-
_ExtraSigs{});
227+
return STDEXEC::__transform_completion_signatures(Completions{},
228+
value_fn,
229+
error_fn,
230+
stopped_fn,
231+
ExtraSigs{});
125232
}
126233
} // namespace experimental::execution
127234

include/exec/detail/shared.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ namespace experimental::execution::__shared
133133
////////////////////////////////////////////////////////////////////////////////////////
134134
template <class _CvSender, class _Env>
135135
using __result_variant_t =
136-
__transform_completion_signatures_t<__completion_signatures_of_t<_CvSender, _Env>,
137-
__mbind_front_q<__decayed_tuple, set_value_t>::__f,
138-
__mbind_front_q<__decayed_tuple, set_error_t>::__f,
139-
__tuple<set_stopped_t>,
140-
__munique<__qq<__variant>>::__f,
141-
__tuple<set_error_t, std::exception_ptr>,
142-
__tuple<set_stopped_t>>;
136+
__transform_reduce_completion_signatures_t<__completion_signatures_of_t<_CvSender, _Env>,
137+
__mbind_front_q<__decayed_tuple, set_value_t>::__f,
138+
__mbind_front_q<__decayed_tuple, set_error_t>::__f,
139+
__tuple<set_stopped_t>,
140+
__munique<__qq<__variant>>::__f,
141+
__tuple<set_error_t, std::exception_ptr>,
142+
__tuple<set_stopped_t>>;
143143

144144
////////////////////////////////////////////////////////////////////////////////////////
145145
template <class _CvChild, class _Env>
@@ -461,12 +461,12 @@ namespace experimental::execution::__shared
461461
};
462462

463463
template <class _Cv, class _CvSender, class _Env>
464-
using __make_completions_t = __try_make_completion_signatures<
464+
using __make_completions_t = __transform_completion_signatures_of_t<
465465
_CvSender,
466466
__env_t<_Env>,
467467
completion_signatures<set_error_t(__mcall1<_Cv, std::exception_ptr>), set_stopped_t()>,
468-
__mtransform<_Cv, __mcompose<__qq<completion_signatures>, __qf<set_value_t>>>,
469-
__mtransform<_Cv, __mcompose<__qq<completion_signatures>, __qf<set_error_t>>>>;
468+
__mtransform<_Cv, __mcompose<__qq<completion_signatures>, __qf<set_value_t>>>::template __f,
469+
__mtransform<_Cv, __mcompose<__qq<completion_signatures>, __qf<set_error_t>>>::template __f>;
470470

471471
// split completes with const T&. ensure_started completes with T&&.
472472
template <class _Tag>

include/exec/into_tuple.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ namespace experimental::execution
5353
STDEXEC::completion_signatures<set_error_t(std::exception_ptr), set_value_t(_Tuple)>;
5454

5555
template <class _Sender, class... _Env>
56-
using __completions_t = transform_completion_signatures<
56+
using __completions_t = __transform_completion_signatures_t<
5757
__completion_signatures_of_t<_Sender, _Env...>,
5858
__minvoke_q<__tuple_completions_t, __result_tuple_t<_Sender, _Env...>>,
5959
__mconst<STDEXEC::completion_signatures<>>::__f>;

include/exec/just_from.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ namespace experimental::execution
115115
{
116116
template <class Fn>
117117
using __f = STDEXEC::__concat_completion_signatures_t<STDEXEC::__call_result_t<Fn, _probe_fn>,
118-
STDEXEC::__eptr_completion>;
118+
STDEXEC::__eptr_completion_t>;
119119
};
120120

121121
template <class Fn>

include/exec/libdispatch_queue.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,14 @@ namespace experimental::execution
258258
STDEXEC::__mbind_front_q<bulk_non_throwing_t, Fun, Shape>,
259259
STDEXEC::__q<STDEXEC::__mand>>::value,
260260
STDEXEC::completion_signatures<>,
261-
STDEXEC::__eptr_completion>;
261+
STDEXEC::__eptr_completion_t>;
262262

263263
template <class... Tys>
264264
using set_value_t =
265265
STDEXEC::completion_signatures<STDEXEC::set_value_t(STDEXEC::__decay_t<Tys>...)>;
266266

267267
template <class Self, class... Env>
268-
using _completions_t = STDEXEC::transform_completion_signatures<
268+
using _completions_t = STDEXEC::__transform_completion_signatures_t<
269269
STDEXEC::__completion_signatures_of_t<STDEXEC::__copy_cvref_t<Self, Sender>, Env...>,
270270
with_error_invoke_t<STDEXEC::__copy_cvref_t<Self, Sender>, Env...>,
271271
set_value_t>;

include/exec/materialize.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ namespace experimental::execution
9595
using __materialize_error = completion_signatures<set_value_t(set_error_t, _Err)>;
9696

9797
template <class _Self, class... _Env>
98-
using __completions_t = __transform_completion_signatures_t<
98+
using __completions_t = __transform_reduce_completion_signatures_t<
9999
__completion_signatures_of_t<__copy_cvref_t<_Self, _Sender>, _Env...>,
100100
__materialize_value,
101101
__materialize_error,
@@ -202,7 +202,7 @@ namespace experimental::execution
202202
using __dematerialize_value = completion_signatures<__decay_t<_Tag>(_Args...)>;
203203

204204
template <class _Self, class... _Env>
205-
using __completions_t = transform_completion_signatures<
205+
using __completions_t = __transform_completion_signatures_t<
206206
__completion_signatures_of_t<__copy_cvref_t<_Self, _Sender>, _Env...>,
207207
completion_signatures<>,
208208
__mtry_q<__dematerialize_value>::template __f>;

0 commit comments

Comments
 (0)