标准库标头 <execution> (C++17)

来自cppreference.com
< cpp‎ | header


 
 
标准库头
通用工具
<any> (C++17)
<bitset>
<bit> (C++20)
<charconv> (C++17)
<expected> (C++23)
<format> (C++20)
<functional>
<optional> (C++17)
<stdbit.h> (C++26)
<tuple> (C++11)
<typeindex> (C++11)
<utility>
<variant> (C++17)
容器
<array> (C++11)
<deque>
<flat_map> (C++23)
<flat_set> (C++23)
<forward_list> (C++11)
<hive> (C++26)
<inplace_vector> (C++26)   
<list>
<map>
<mdspan> (C++23)
<queue>
<set>
<span> (C++20)
<stack>
<unordered_map> (C++11)
<unordered_set> (C++11)
<vector>
迭代器
<iterator>
范围
<generator> (C++23)
<ranges> (C++20)
 

此头文件是执行算法库的一部分。

目录

测试类是否表示某种执行策略
(类模板) [编辑]
在命名空间 std::execution 定义
执行策略类型
(类) [编辑]

常量

在命名空间 std::execution 定义
(C++17)(C++17)(C++17)(C++20)
全局执行策略对象
(常量) [编辑]

[编辑] 概要

namespace std {
  // 执行策略类型特征
  template<class T>
  struct is_execution_policy;                                           // 独立
  template<class T>
  constexpr bool is_execution_policy_v = is_execution_policy<T>::value; // 独立
}
 
namespace std::execution {
  // 顺序执行策略
  class sequenced_policy;
 
  // 并行执行策略
  class parallel_policy;
 
  // 并行及无序执行策略
  class parallel_unsequenced_policy;
 
  // 无序执行策略
  class unsequenced_policy;
 
  // 执行策略对象
  inline constexpr sequenced_policy seq{ /* 未指定 */ };
  inline constexpr parallel_policy par{ /* 未指定 */ };
  inline constexpr parallel_unsequenced_policy par_unseq{ /* 未指定 */ };
  inline constexpr unsequenced_policy unseq{ /* 未指定 */ };
}
 
namespace std {
  // 辅助概念
  template<class T>
  concept /*movable-value*/ = /* 见描述 */; // 仅用于阐述
 
  template<class From, class To>
  concept /*decays-to*/ = same_as<decay_t<From>, To>; // 仅用于阐述
 
  template<class T>
  concept /*class-type*/ = /*decays-to*/<T, T> && is_class_v<T>; // 仅用于阐述
 
  // 可查询对象
  template<class T>
  concept /*queryable*/ = /* 见描述 */; // 仅用于阐述
 
  // 查询
  struct forwarding_query_t
  { /* 未指定 */
  };
  struct get_allocator_t
  { /* 未指定 */
  };
  struct get_stop_token_t
  { /* 未指定 */
  };
 
  inline constexpr forwarding_query_t forwarding_query{};
  inline constexpr get_allocator_t get_allocator{};
  inline constexpr get_stop_token_t get_stop_token{};
 
  template<class T>
  using stop_token_of_t = remove_cvref_t<decltype(get_stop_token(declval<T>()))>;
 
  template<class T>
  concept /*forwarding-query*/ = forwarding_query(T{}); // 仅用于阐述
}
 
namespace std::execution {
  // 查询
  struct get_domain_t
  { /* 未指定 */
  };
  struct get_scheduler_t
  { /* 未指定 */
  };
  struct get_delegation_scheduler_t
  { /* 未指定 */
  };
  struct get_forward_progress_guarantee_t
  { /* 未指定 */
  };
  template<class CPO>
  struct get_completion_scheduler_t
  { /* 未指定 */
  };
 
  inline constexpr get_domain_t get_domain{};
  inline constexpr get_scheduler_t get_scheduler{};
  inline constexpr get_delegation_scheduler_t get_delegation_scheduler{};
  enum class forward_progress_guarantee;
  inline constexpr get_forward_progress_guarantee_t get_forward_progress_guarantee{};
  template<class CPO>
  constexpr get_completion_scheduler_t<CPO> get_completion_scheduler{};
 
  struct get_env_t
  { /* 未指定 */
  };
  inline constexpr get_env_t get_env{};
 
  template<class T>
  using env_of_t = decltype(get_env(declval<T>()));
 
  template<class QueryTag, class ValueType>
  struct prop;
 
  template</*queryable*/... Envs>
  struct env;
 
  // 执行域
  struct default_domain;
 
  // 调度器
  struct scheduler_t
  {};
 
  template<class Sch>
  concept scheduler = /* 见描述 */;
 
  // 接收器
  struct receiver_t
  {};
 
  template<class Rcvr>
  concept receiver = /* 见描述 */;
 
  template<class Rcvr, class Completions>
  concept receiver_of = /* 见描述 */;
 
  struct set_value_t
  { /* 未指定 */
  };
  struct set_error_t
  { /* 未指定 */
  };
  struct set_stopped_t
  { /* 未指定 */
  };
 
  inline constexpr set_value_t set_value{};
  inline constexpr set_error_t set_error{};
  inline constexpr set_stopped_t set_stopped{};
 
  // 操作状态
  struct operation_state_t
  {};
 
  template<class O>
  concept operation_state = /* 见描述 */;
 
  struct start_t;
  inline constexpr start_t start{};
 
  // 发送器
  struct sender_t
  {};
 
  template<class Sndr>
  concept sender = /* 见描述 */;
 
  template<class Sndr, class Env = env<>>
  concept sender_in = /* 见描述 */;
 
  template<class Sndr, class Rcvr>
  concept sender_to = /* 见描述 */;
 
  template<class... Ts>
  struct /*type-list*/; // 仅用于阐述
 
  // 完成签名
  struct get_completion_signatures_t;
  inline constexpr get_completion_signatures_t get_completion_signatures{};
 
  template<class Sndr, class Env = env<>>
    requires sender_in<Sndr, Env>
  using completion_signatures_of_t =
    /*call-result-t*/<get_completion_signatures_t, Sndr, Env>;
 
  template<class... Ts>
  using /*decayed-tuple*/ = tuple<decay_t<Ts>...>; // 仅用于阐述
 
  template<class... Ts>
  using /*variant-or-empty*/ = /* 见描述 */; // 仅用于阐述
 
  template<class Sndr,
           class Env                        = env<>,
           template<class...> class Tuple   = /*decayed-tuple*/,
           template<class...> class Variant = /*variant-or-empty*/>
    requires sender_in<Sndr, Env>
  using value_types_of_t = /* 见描述 */;
 
  template<class Sndr,
           class Env                        = env<>,
           template<class...> class Variant = /*variant-or-empty*/>
    requires sender_in<Sndr, Env>
  using error_types_of_t = /* 见描述 */;
 
  template<class Sndr, class Env = env<>>
    requires sender_in<Sndr, Env>
  constexpr bool sends_stopped = /* 见描述 */;
 
  template<class Sndr, class Env>
  using /*single-sender-value-type*/ = /* 见描述 */; // 仅用于阐述
 
  template<class Sndr, class Env>
  concept /*single-sender*/ = /* 见描述 */; // 仅用于阐述
 
  template<sender Sndr>
  using tag_of_t = /* 见描述 */;
 
  // 发送器变换
  template<class Domain, sender Sndr, /*queryable*/... Env>
    requires(sizeof...(Env) <= 1)
  constexpr sender decltype(auto) transform_sender(
    Domain dom,
    Sndr&& sndr,
    const Env&... env) noexcept(/* 见描述 */);
 
  // 环境变换
  template<class Domain, sender Sndr, /*queryable*/ Env>
  constexpr /*queryable*/ decltype(auto) transform_env(Domain dom,
                                                       Sndr&& sndr,
                                                       Env&& env) noexcept;
 
  // 发送器算法的应用
  template<class Domain, class Tag, sender Sndr, class... Args>
  constexpr decltype(auto) apply_sender(Domain dom,
                                        Tag,
                                        Sndr&& sndr,
                                        Args&&... args) noexcept(/* 见描述 */);
 
  // connect 发送器算法
  struct connect_t;
  inline constexpr connect_t connect{};
 
  template<class Sndr, class Rcvr>
  using connect_result_t = decltype(connect(declval<Sndr>(), declval<Rcvr>()));
 
  // 发送器工厂
  struct just_t
  { /* 未指定 */
  };
  struct just_error_t
  { /* 未指定 */
  };
  struct just_stopped_t
  { /* 未指定 */
  };
  struct schedule_t
  { /* 未指定 */
  };
 
  inline constexpr just_t just{};
  inline constexpr just_error_t just_error{};
  inline constexpr just_stopped_t just_stopped{};
  inline constexpr schedule_t schedule{};
  inline constexpr /* 未指定 */ read_env{};
 
  template<scheduler Sndr>
  using schedule_result_t = decltype(schedule(declval<Sndr>()));
 
  // 发送器适配器
  template</*class-type*/ D>
  struct sender_adaptor_closure
  {};
 
  struct starts_on_t
  { /* 未指定 */
  };
  struct continues_on_t
  { /* 未指定 */
  };
  struct on_t
  { /* 未指定 */
  };
  struct schedule_from_t
  { /* 未指定 */
  };
  struct then_t
  { /* 未指定 */
  };
  struct upon_error_t
  { /* 未指定 */
  };
  struct upon_stopped_t
  { /* 未指定 */
  };
  struct let_value_t
  { /* 未指定 */
  };
  struct let_error_t
  { /* 未指定 */
  };
  struct let_stopped_t
  { /* 未指定 */
  };
  struct bulk_t
  { /* 未指定 */
  };
  struct split_t
  { /* 未指定 */
  };
  struct when_all_t
  { /* 未指定 */
  };
  struct when_all_with_variant_t
  { /* 未指定 */
  };
  struct into_variant_t
  { /* 未指定 */
  };
  struct stopped_as_optional_t
  { /* 未指定 */
  };
  struct stopped_as_error_t
  { /* 未指定 */
  };
 
  inline constexpr starts_on_t starts_on{};
  inline constexpr continues_on_t continues_on{};
  inline constexpr on_t on{};
  inline constexpr schedule_from_t schedule_from{};
  inline constexpr then_t then{};
  inline constexpr upon_error_t upon_error{};
  inline constexpr upon_stopped_t upon_stopped{};
  inline constexpr let_value_t let_value{};
  inline constexpr let_error_t let_error{};
  inline constexpr let_stopped_t let_stopped{};
  inline constexpr bulk_t bulk{};
  inline constexpr split_t split{};
  inline constexpr when_all_t when_all{};
  inline constexpr when_all_with_variant_t when_all_with_variant{};
  inline constexpr into_variant_t into_variant{};
  inline constexpr stopped_as_optional_t stopped_as_optional{};
  inline constexpr stopped_as_error_t stopped_as_error{};
 
  // 发送器与接收器工具
 
  template<class Fn>
  concept /*completion-signature*/ = /* 见描述 */; // 仅用于阐述
 
  template</*completion-signature*/... Fns>
  struct completion_signatures
  {};
 
  template<class Sigs>
  concept /*valid-completion-signatures*/ = /* 见描述 */; // 仅用于阐述
 
  template</*valid-completion-signatures*/ InputSignatures,
           /*valid-completion-signatures*/ AdditionalSignatures = completion_signatures<>,
           template<class...> class SetValue                    = /* 见描述 */,
           template<class> class SetError                       = /* 见描述 */,
           /*valid-completion-signatures*/ SetStopped =
             completion_signatures<set_stopped_t()>>
  using transform_completion_signatures = completion_signatures</* 见描述 */>;
 
  template<sender Sndr,
           class Env                                            = env<>,
           /*valid-completion-signatures*/ AdditionalSignatures = completion_signatures<>,
           template<class...> class SetValue                    = /* 见描述 */,
           template<class> class SetError                       = /* 见描述 */,
           /*valid-completion-signatures*/ SetStopped =
             completion_signatures<set_stopped_t()>>
    requires sender_in<Sndr, Env>
  using transform_completion_signatures_of =
    transform_completion_signatures<completion_signatures_of_t<Sndr, Env>,
                                    AdditionalSignatures,
                                    SetValue,
                                    SetError,
                                    SetStopped>;
 
  // run_loop
  class run_loop;
}
 
namespace std::this_thread {
  // 消耗器
  struct sync_wait_t
  { /* 未指定 */
  };
  struct sync_wait_with_variant_t
  { /* 未指定 */
  };
 
  inline constexpr sync_wait_t sync_wait{};
  inline constexpr sync_wait_with_variant_t sync_wait_with_variant{};
}
 
namespace std::execution {
  struct as_awaitable_t
  { /* 未指定 */
  };
  inline constexpr as_awaitable_t as_awaitable{};
 
  template</*class-type*/ Promise>
  struct with_awaitable_senders;
}

[编辑] 辅助概念

namespace std {
  template<class T>
  concept /*movable-value*/ = // 仅用于阐述
    move_constructible<decay_t<T>> && constructible_from<decay_t<T>, T> &&
    (!is_array_v<remove_reference_t<T>>);
}
 
namespace std {
  template<class T>
  concept /*queryable*/ = destructible<T>; // 仅用于阐述
}
 
namespace std::execution {
  template<class Sndr, class Env>
  concept /*single-sender*/ = sender_in<Sndr, Env> && requires {
    typename /*single-sender-value-type*/<Sndr, Env>;
  };
}

[编辑] 辅助类

namespace std::execution {
  struct /*empty-variant*/
  { // 仅用于阐述
    /*empty-variant*/() = delete;
  };
}

[编辑] enum std::forward_progress_guarantee

namespace std::execution {
  enum class forward_progress_guarantee
  {
    concurrent,
    parallel,
    weakly_parallel
  };
}

[编辑] 概念 scheduler

namespace std::execution {
  template<class Sch>
  concept scheduler =
    derived_from<typename remove_cvref_t<Sch>::scheduler_concept, scheduler_t> &&
    /*queryable*/<Sch> &&
    requires(Sch&& sch) {
      {
        schedule(std::forward<Sch>(sch))
      } -> sender;
      {
        auto(get_completion_scheduler<set_value_t>(
          get_env(schedule(std::forward<Sch>(sch)))))
      } -> same_as<remove_cvref_t<Sch>>;
    } && equality_comparable<remove_cvref_t<Sch>> &&
    copy_constructible<remove_cvref_t<Sch>>;
}

[编辑] 概念 receiver

namespace std::execution {
  template<class Rcvr>
  concept receiver =
    derived_from<typename remove_cvref_t<Rcvr>::receiver_concept, receiver_t> &&
    requires(const remove_cvref_t<Rcvr>& rcvr) {
      {
        get_env(rcvr)
      } -> /*queryable*/;
    } && move_constructible<remove_cvref_t<Rcvr>> && // 右值是可移动的
    constructible_from<remove_cvref_t<Rcvr>, Rcvr>;  // 左值是可复制的
 
  template<class Signature, class Rcvr>
  concept /*valid-completion-for*/ = requires(Signature* sig) {
    []<class Tag, class... Args>(Tag(*)(Args...))
      requires /*callable*/<Tag, remove_cvref_t<Rcvr>, Args...>
    {
    }
    (sig);
  };
 
  template<class Rcvr, class Completions>
  concept /*has-completions*/ = requires(Completions* completions) {
    []</*valid-completion-for*/<Rcvr>... Sigs>(completion_signatures<Sigs...>*) {
    }(completions);
  };
 
  template<class Rcvr, class Completions>
  concept receiver_of = receiver<Rcvr> && /*has-completions*/<Rcvr, Completions>;
}

[编辑] 概念 operation_state

namespace std::execution {
  template<class O>
  concept operation_state =
    derived_from<typename O::operation_state_concept, operation_state_t> &&
    is_object_v<O> && requires(O& o) {
      {
        start(o)
      } noexcept;
    };
}