Daily bit(e) of C++ | std::transform
Daily bit(e) of C++ ♻️115, The "copy with transformation" algorithm: std::transform.
The std::transform algorithm can copy elements from one range to another, applying a transformation to each element. The transformation can change the type of the range.
The algorithm also provides a binary variant which can be used to reduce two ranges into one.
The output range is permitted to be one of the input ranges (it cannot be offset); however, if the transformation can be applied in place, a range for loop or a std::for_each is preferable.
Both variants offer C++17 parallel and C++20 range versions.