33 Execution control library [exec] (original) (raw)
33.13 Coroutine utilities [exec.coro.util]
33.13.6 execution::task [exec.task]
33.13.6.2 Class template task [task.class]
namespace std::execution { template<class T = void, class Environment = env<>> class task { template<receiver Rcvr> class state; public: using sender_concept = sender_t;using completion_signatures = see below;using allocator_type = see below;using scheduler_type = see below;using stop_source_type = see below;using stop_token_type = decltype(declval<stop_source_type>().get_token());using error_types = see below;class promise_type; task(task&&) noexcept;~task();template<receiver Rcvr> state<Rcvr> connect(Rcvr&& rcvr) &&;private: coroutine_handle<promise_type> handle; };}
task<T, E> models sender ([exec.snd]) if T is void, a reference type, or a cv-unqualified non-array object type and E is a class type.
Otherwise a program that instantiates the definition of task<T, E>is ill-formed.
The nested types of task template specializations are determined based on the Environment parameter:
- allocator_type is Environment::allocator_typeif that qualified-id is valid and denotes a type,allocator<byte> otherwise.
- scheduler_type is Environment::scheduler_typeif that qualified-id is valid and denotes a type,task_scheduler otherwise.
- stop_source_type is Environment::stop_source_typeif that qualified-id is valid and denotes a type,inplace_stop_source otherwise.
- error_types is Environment::error_types if that qualified-id is valid and denotes a type,completion_signatures<set_error_t(exception_ptr)> otherwise.
A program is ill-formed if error_types is not a specialization of execution::completion_signaturesor if the template arguments of that specialization contain an element which is not of the formset_error_t(E) for some type E.
The type alias completion_signatures is a specialization of execution::completion_signatures with the template arguments (in unspecified order):
- set_value_t() if T is void, and set_value_t(T) otherwise;
- template arguments of the specialization ofexecution::completion_signatures denoted by error_types; and
- set_stopped_t().
allocator_type shall meet the _Cpp17Allocator_requirements.