A parallel algorithm distributes work across multiple execution agents. In C++17, many Standard Library algorithms have overloads that accept an execution policy. The policy specifies how the call may run: `std::execution::par` permits parallel execution but does not require the library to use multiple threads. section 10.1
std::vector<int> my_data;
std::sort(std::execution::par,my_data.begin(),my_data.end());
!@%STYLE%@!
{"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":1,\"ch\":10},{\"line\":1,\"ch\":29}]]"}
!@%STYLE%@!
This call sorts a vector with a policy that permits parallel execution. section 10.1
Choosing a policy can change algorithm behavior, complexity requirements, and restrictions on the code. Exception safety also needs care: exceptions from work running on other threads cannot simply propagate through the caller’s stack. Custom parallel algorithms such as `parallel_accumulate` illustrate how futures and thread-joining safeguards can address these risks. section 10.4 section 8.4.1
