The parallel unsequenced policy, std::execution::par_unseq , executes the algorithm in parallel like the parallel policy, but with the addition that it may also vectorize the loop using, for example, SIMD instructions if plausible.
In addition to the vectorization, it has stricter conditions for the predicates than std::execution::par:
- Predicates may not throw, doing so will cause undefined behavior or an instant crash
- Predicates may not use a mutex for synchronization, doing so might cause a deadlock
The following example might cause a deadlock as the std::execution::par_unseq might execute concurrently on the same thread:
auto trees = std::vector<std::string>{"Pine", "Birch", "Oak"};auto m = std::mutex{};