Algorithms Library

Execution policies

Most algorithms have overloads that accept execution policies. The standard library algorithms support several execution policies, and the library provides corresponding execution policy types and objects. Users may select an execution policy statically by invoking a parallel algorithm with an execution policy object of the corresponding type.

Standard library implementations (but not the users) may define additional execution policies as an extension. The semantics of parallel algorithms invoked with an execution policy object of implementation-defined type is implementation-defined.

Parallel version of algorithms (except for std::for_each and std::for_each_n) are allowed to make arbitrary copies of elements from ranges, as long as both std::is_trivially_copy_constructible_v<T> and std::is_trivially_destructible_v<T> are true, where T is the type of elements.

Defined in header <execution>
Defined in namespace std::execution
sequenced_policyparallel_policyparallel_unsequenced_policyunsequenced_policy(C++17)(C++17)(C++17)(C++20) execution policy types (class) [edit]
seqparpar_unsequnseq(C++17)(C++17)(C++17)(C++20) global execution policy objects (constant) [edit]
Defined in namespace std
is_execution_policy(C++17) test whether a class represents an execution policy (class template) [edit]
Feature-test macro Value Std Feature
__cpp_lib_parallel_algorithm 201603L (C++17) Parallel algorithms
__cpp_lib_execution 201603L (C++17) Execution policies
201902L (C++20) std::execution::unsequenced_policy

Từ khóa » Thư Viện Algorithm