Skip to content

Commit 052e38a

Browse files
committed
add a get_completion_domain<void> query
1 parent 250f357 commit 052e38a

File tree

5 files changed

+31
-20
lines changed

5 files changed

+31
-20
lines changed

include/stdexec/__detail/__completion_signatures.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ namespace stdexec {
371371

372372
namespace __detail {
373373
template <class _Tag, class _Sigs>
374-
extern const std::size_t __count_of;
374+
inline constexpr std::size_t __count_of = 0;
375375

376376
template <class _Sigs>
377377
inline constexpr std::size_t __count_of<set_value_t, _Sigs> =

include/stdexec/__detail/__continues_on.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ namespace stdexec {
261261
}
262262

263263
//! @overload
264-
template <__not_same_as<set_value_t> _SetTag, class... _Env>
264+
template <__one_of<set_error_t, set_stopped_t> _SetTag, class... _Env>
265265
requires(!__has_decay_copy_errors<_SetTag, _Env...>())
266266
[[nodiscard]]
267267
constexpr auto

include/stdexec/__detail/__domain.hpp

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ namespace stdexec {
285285
//! custom implementation of a sender algorithm.
286286
//!
287287
//! @tparam _Tag one of set_value_t, set_error_t, or set_stopped_t
288-
template <__completion_tag _Tag>
288+
template <class _Tag>
289289
struct get_completion_domain_t {
290290
template <class Sig>
291291
static inline constexpr get_completion_domain_t<_Tag> (*signature)(Sig) = nullptr;
@@ -320,13 +320,15 @@ namespace stdexec {
320320
static consteval auto __check_domain(_Domain) noexcept -> _Domain {
321321
// Sanity check: if a completion scheduler can be determined from the attributes
322322
// (not the environment), then its domain must match the domain returned by the attributes.
323-
if constexpr (__callable<get_completion_scheduler_t<_Tag>, const _Attrs&, const _Env&...>) {
324-
using __sch_t =
325-
__call_result_t<get_completion_scheduler_t<_Tag>, const _Attrs&, const _Env&...>;
326-
// Skip check if the "scheduler" is the same as the domain or the attributes
327-
// (this can happen with __prop_like which answers any query with the same type)
328-
if constexpr (!__same_as<__sch_t, _Attrs>) {
329-
__check_domain_<__sch_t, _Env...>(_Domain{});
323+
if constexpr (!__same_as<_Tag, void>) {
324+
if constexpr (__callable<get_completion_scheduler_t<_Tag>, const _Attrs&, const _Env&...>) {
325+
using __sch_t =
326+
__call_result_t<get_completion_scheduler_t<_Tag>, const _Attrs&, const _Env&...>;
327+
// Skip check if the "scheduler" is the same as the domain or the attributes
328+
// (this can happen with __prop_like which answers any query with the same type)
329+
if constexpr (!__same_as<__sch_t, _Attrs>) {
330+
__check_domain_<__sch_t, _Env...>(_Domain{});
331+
}
330332
}
331333
}
332334
return {};
@@ -338,6 +340,16 @@ namespace stdexec {
338340
if constexpr (__callable<__read_query_t, const _Attrs&, const _Env&...>) {
339341
using __domain_t = __call_result_t<__read_query_t, const _Attrs&, const _Env&...>;
340342
return __check_domain<_Attrs, _Env...>(__domain_t{});
343+
// Otherwise, if _Tag is void, fall back to querying for the set_value_t completion domain:
344+
} else if constexpr (__same_as<_Tag, void>) {
345+
if constexpr (
346+
__callable<get_completion_domain_t<set_value_t>, const _Attrs&, const _Env&...>) {
347+
using __domain_t =
348+
__call_result_t<get_completion_domain_t<set_value_t>, const _Attrs&, const _Env&...>;
349+
return __check_domain<_Attrs, _Env...>(__domain_t{});
350+
} else {
351+
return void();
352+
}
341353
}
342354
// Otherwise, if __attrs has a completion scheduler, we can ask that scheduler for its
343355
// completion domain.
@@ -433,9 +445,11 @@ namespace stdexec {
433445
using __queries::get_domain_t;
434446

435447
#if !STDEXEC_GCC() || defined(__OPTIMIZE_SIZE__)
436-
template <__completion_tag _Query>
437-
inline constexpr get_completion_domain_t<_Query> get_completion_domain{};
448+
template <class _Tag>
449+
inline constexpr get_completion_domain_t<_Tag> get_completion_domain{};
438450
#else
451+
template <>
452+
inline constexpr get_completion_domain_t<> get_completion_domain<>{};
439453
template <>
440454
inline constexpr get_completion_domain_t<set_value_t> get_completion_domain<set_value_t>{};
441455
template <>

include/stdexec/__detail/__execution_fwd.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ namespace stdexec {
129129
struct get_stop_token_t;
130130
template <__completion_tag _CPO>
131131
struct get_completion_scheduler_t;
132-
template <__completion_tag _CPO>
132+
template <class _CPO = void>
133133
struct get_completion_domain_t;
134134
template <__completion_tag _CPO>
135135
struct get_completion_behavior_t;
@@ -157,7 +157,7 @@ namespace stdexec {
157157
extern const get_stop_token_t get_stop_token;
158158
template <__completion_tag _CPO>
159159
extern const get_completion_scheduler_t<_CPO> get_completion_scheduler;
160-
template <__completion_tag _CPO>
160+
template <class _CPO>
161161
extern const get_completion_domain_t<_CPO> get_completion_domain;
162162
extern const get_domain_t get_domain;
163163

include/stdexec/__detail/__transform_sender.hpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ namespace stdexec {
5353
return __get_declfn<__result_t, _Env, (_Nothrow && __is_nothrow)>();
5454
} else {
5555
using __transform_recurse_t =
56-
__transform_sender_t<__completing_domain_t<set_value_t, __result_t, _Env>, set_value_t>;
56+
__transform_sender_t<__completing_domain_t<void, __result_t, _Env>, set_value_t>;
5757
return __transform_recurse_t::template __get_declfn<
5858
__result_t,
5959
_Env,
@@ -83,7 +83,7 @@ namespace stdexec {
8383
__domain_t().transform_sender(_OpTag(), static_cast<_Sndr&&>(__sndr), __env), __env);
8484
} else {
8585
using __transform_recurse_t =
86-
__transform_sender_t<__completing_domain_t<set_value_t, __result_t, _Env>, set_value_t>;
86+
__transform_sender_t<__completing_domain_t<void, __result_t, _Env>, set_value_t>;
8787
return __transform_recurse_t()(
8888
__domain_t().transform_sender(_OpTag(), static_cast<_Sndr&&>(__sndr), __env), __env);
8989
}
@@ -110,10 +110,7 @@ namespace stdexec {
110110
template <class _Sndr, class _Env>
111111
using __impl_fn_t = __compose<
112112
__detail::__transform_sender_t<__detail::__starting_domain_t<_Env>, start_t>,
113-
__detail::__transform_sender_t<
114-
__detail::__completing_domain_t<set_value_t, _Sndr, _Env>,
115-
set_value_t
116-
>
113+
__detail::__transform_sender_t<__detail::__completing_domain_t<void, _Sndr, _Env>, set_value_t>
117114
>;
118115

119116
public:

0 commit comments

Comments
 (0)