In [exec.spawn.future]/p7, we see this:
- Let
spawn-future-state be the exposition-only class template:
namespace std::execution {
template<class Alloc, scope_token Token, sender Sender, class Env>
struct spawn-future-state // exposition only
: spawn-future-state-base<completion_signatures_of_t<future-spawned-sender<Sender, Env>>> {
using sigs-t = // exposition only
completion_signatures_of_t<future-spawned-sender<Sender, Env>>;
where spawn-future-sender<Sender, Env> is the type of write_env(stop-when(declval<Sender>(), declval<stoken-t>()), declval<Env>()).
The problem happens in the definition of sigs-t. There is a difference between asking for a sender's completion signatures with an empty environment, and asking with no environment.
In sigs-t, we are asking for the completion signatures with no environment. That is asking the sender for its non-dependent completions. But if Sender is a dependent sender, then so is future-spawned-sender<Sender, Env>, and so this line will not compile. A dependent sender cannot provide non-dependent completion signatures.
The spawn_future algorithm connects the future-spawned-sender with a receiver that has an empty environment. Therefore, we should be using the empty environment when computing the future-spawned-sender's completion signatures.
Proposed Resolution
Change [exec.spawn.future]/p7 as follows
namespace std::execution {
template<class Alloc, scope_token Token, sender Sender, class Env>
struct spawn-future-state // exposition only
- : spawn-future-state-base<completion_signatures_of_t<future-spawned-sender<Sender, Env>>> {
+ : spawn-future-state-base<completion_signatures_of_t<future-spawned-sender<Sender, Env>, env<>>> {
using sigs-t = // exposition only
- completion_signatures_of_t<future-spawned-sender<Sender, Env>>;
+ completion_signatures_of_t<future-spawned-sender<Sender, Env>, env<>>;
In [exec.spawn.future]/p7, we see this:
where
spawn-future-sender<Sender, Env>is the type ofwrite_env(stop-when(declval<Sender>(), declval<stoken-t>()), declval<Env>()).The problem happens in the definition of
sigs-t. There is a difference between asking for a sender's completion signatures with an empty environment, and asking with no environment.In
sigs-t, we are asking for the completion signatures with no environment. That is asking the sender for its non-dependent completions. But ifSenderis a dependent sender, then so isfuture-spawned-sender<Sender, Env>, and so this line will not compile. A dependent sender cannot provide non-dependent completion signatures.The
spawn_futurealgorithm connects thefuture-spawned-senderwith a receiver that has an empty environment. Therefore, we should be using the empty environment when computing thefuture-spawned-sender's completion signatures.Proposed Resolution
Change [exec.spawn.future]/p7 as follows