Quick summary ↬ The library in C++ STL C++17 introduces several new algorithms and overloads, including the following:
Numeric library C++17 addition
-
std::transform_reduce
: This algorithm applies a binary operation to elements of a range that have been transformed by a unary operation, and returns the result of the accumulation of the transformed elements using the binary operation. -
std::exclusive_scan
: This algorithm performs an exclusive prefix sum on a range of elements, where each element is the sum of the previous elements in the range, excluding the element itself. -
std::inclusive_scan
: This algorithm performs an inclusive prefix sum on a range of elements, where each element is the sum of the previous elements in the range, including the element itself. -
std::sample
: This algorithm randomly samples a specified number of elements from a range. -
Overloads of
std::reduce
: Thestd::reduce
algorithm has several new overloads that allow the user to specify execution policies, as well as a binary operation and a combination function that can be used to improve performance for certain types of calculations. -
Overloads of
std::inner_product
: Thestd::inner_product
algorithm has several new overloads that allow the user to specify execution policies, as well as a binary operation and a combination function that can be used to improve performance for certain types of calculations. -
Overloads of
std::transform_exclusive_scan
andstd::transform_inclusive_scan
: These algorithms combine the functionality of std::transform, std::exclusive_scan, and std::inclusive_scan into a single operation. -
Execution policies: Many algorithms in the
library now have overloads that take an execution policy as the first argument. Execution policies allow the user to specify how the algorithm should be executed, such as whether to execute it in parallel or sequentially. -
std::gcd
andstd::lcm
: These functions calculate the greatest common divisor and least common multiple of two integers, respectively. -
std::midpoint
: This function calculates the midpoint of two values, and is useful for avoiding overflow or underflow when calculating the average of two values. This is C++20 addition. -
Overloads of
std::accumulate
: Thestd::accumulate
algorithm has several new overloads that allow the user to specify execution policies, as well as a binary operation and an initial value that can be used to improve performance for certain types of calculations. -
Overloads of
std::partial_sum
: Thestd::partial_sum
algorithm has several new overloads that allow the user to specify execution policies, as well as a binary operation that can be used to improve performance for certain types of calculations. -
Overloads of
std::adjacent_difference
: Thestd::adjacent_difference
algorithm has several new overloads that allow the user to specify execution policies, as well as a binary operation that can be used to improve performance for certain types of calculations.
These new additions to the