DEV Community

Cover image for std::transform in STL
Lalit Kumar
Lalit Kumar

Posted on

std::transform in STL

We use numerous functions in C++ to simplify our process and some of them are built-in C++ itself. The one we are talking about is the transform present in STL. To use this function we have to include header file .

What is the use of this function?

Use of this function is kind of cool, it makes our process or tasks easy to perform in a specific way. This function is used to perform an operation on all elements. According to some people it is also defined as For example: adding two arrays or squares of each element of an array and store the result in another array.
Transform function works in two different modes.

Unary operation mode

In unary operation mode, it applies the operation to the elements in the range and stores the value returned by each operation in the range that begins at the result.

Binary operation mode

In binary operation mode uses each of the elements in the range as the first argument and the specific argument in the range that begins at the second argument. The value returned by each call is stored in the range that begins at the result.

you can read more at

%https://www.kodlogs.com/blog/2641/std-transform-in-stl%

Top comments (0)