As of C++17, the STL library has been extended with parallel versions of most, but not all, algorithms. Changing your algorithms to execute in parallel is only a matter of adding a parameter that tells the algorithm which parallel execution policy to use.
As stressed earlier in this book, if your code base is based upon STL algorithms, or at least if you have the habit of writing C++ by using algorithms, you get an instant performance boost almost for free by adding an execution policy where suitable.
auto roller_coasters = std::vector<std::string>{ "woody", "steely", "loopy", "upside_down" };
Sequential version |
Parallel version |
auto loopy_coaster = *std::find( roller_coasters.begin(), roller_coasters.end(), "loopy" ... |