Skip to content

Commit

Permalink
attempt to work around clang bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ericniebler committed Nov 4, 2023
1 parent ba97c4a commit 70e8a9e
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions include/stdexec/execution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,19 @@ namespace stdexec {
/////////////////////////////////////////////////////////////////////////////
// [execution.transform_sender]
namespace __domain {
struct __transform_env {
template <class _Domain, class _Sender, class _Env>
STDEXEC_ATTRIBUTE((always_inline))
/*constexpr*/ decltype(auto)
operator()(_Domain __dom, _Sender&& __sndr, _Env&& __env) const noexcept {
if constexpr (__domain::__has_transform_env<_Domain, _Sender, _Env>) {
return __dom.transform_env((_Sender&&) __sndr, (_Env&&) __env);
} else {
return default_domain().transform_env((_Sender&&) __sndr, (_Env&&) __env);
}
}
};

struct __transform_sender {
template <class _Domain, class _Sender>
STDEXEC_ATTRIBUTE((always_inline))
Expand All @@ -1231,35 +1244,27 @@ namespace stdexec {
}
};

struct __transform_env {
template <class _Domain, class _Sender, class _Env>
STDEXEC_ATTRIBUTE((always_inline))
struct __transform_dependent_sender {
// If we are doing a lazy customization of a type whose domain is value-dependent (e.g.,
// let_value), first transform the sender to determine the domain. Then continue transforming
// the sender with the requested domain.
template <class _Domain, sender_expr _Sender, class _Env>
requires same_as<__sender_domain_of_t<_Sender>, dependent_domain>
/*constexpr*/ decltype(auto)
operator()(_Domain __dom, _Sender&& __sndr, _Env&& __env) const noexcept {
if constexpr (__domain::__has_transform_env<_Domain, _Sender, _Env>) {
return __dom.transform_env((_Sender&&) __sndr, (_Env&&) __env);
} else {
return default_domain().transform_env((_Sender&&) __sndr, (_Env&&) __env);
}
operator()(_Domain __dom, _Sender&& __sndr, const _Env& __env) const {
static_assert(__none_of<_Domain, dependent_domain>);
return (*this)(__dom, dependent_domain().transform_sender((_Sender&&) __sndr, __env), __env);
}
};
} // namespace __domain

/////////////////////////////////////////////////////////////////////////////
// [execution.transform_sender]
inline constexpr struct transform_sender_t : __domain::__transform_sender {
inline constexpr struct transform_sender_t
: __domain::__transform_sender
, __domain::__transform_dependent_sender {
using __domain::__transform_sender::operator();

// If we are doing a lazy customization of a type whose domain is value-dependent (e.g.,
// let_value), first transform the sender to determine the domain. Then continue transforming
// the sender with the requested domain.
template <class _Domain, sender_expr _Sender, class _Env>
requires same_as<__sender_domain_of_t<_Sender>, dependent_domain>
/*constexpr*/ decltype(auto)
operator()(_Domain __dom, _Sender&& __sndr, const _Env& __env) const {
static_assert(__none_of<_Domain, dependent_domain>);
return (*this)(__dom, dependent_domain().transform_sender((_Sender&&) __sndr, __env), __env);
}
using __domain::__transform_dependent_sender::operator();
} transform_sender{};

template <class _Domain, class _Sender, class... _Env>
Expand Down

0 comments on commit 70e8a9e

Please sign in to comment.