ranges::views::transform_fn Struct Reference

`#include <range/v3/view/transform.hpp>`

Inheritance diagram for ranges::views::transform_fn:

## Public Member Functions

template<typename Fun >
constexpr auto | operator() (Fun fun) const
Public Member Functions inherited from ranges::views::transform_base_fn
template<typename Rng , typename Fun >
CPP_TEMPLATE_AUX_0 | c (requires transformable_range< Rng, Fun >) ccconstexpr transform_view< all_t< Rng >
template<typename Rng1 , typename Rng2 , typename Fun >
CPP_TEMPLATE_AUX_0 | c (requires transformable_ranges< Rng1, Rng2, Fun >) ccconstexpr transform2_view< all_t< Rng1 >
CPP_TEMPLATE_AUX_0 Fun | operator() (Rng &&rng, Fun fun) const
CPP_TEMPLATE_AUX_0 Fun | operator() (Rng1 &&rng1, Rng2 &&rng2, Fun fun) const

## Related Functions

(Note that these are not member functions.)
constexpr transform_fn | transform {}

## Additional Inherited Members

Public Attributes inherited from ranges::views::transform_base_fn
CPP_TEMPLATE_AUX_0 | all_t< Rng2 >

## Detailed Description

# ranges::views::transform

The transform view takes in a function `T -> U` and converts an input range of `T` into an output range of `U` by calling the function on every element of the input range.

## Example

#include <iostream>
#include <vector>
#include <range/v3/view/transform.hpp>
int main()
{
std::vector<int> numbers{1, 2, 3};
auto halved = numbers
// Divide each integer by 2, converting it into a double
| ranges::views::transform([](const int& num) {
return num / 2.0;
});
std::cout << halved << '\n';
}
meta::transform
_t< detail::transform_< Args... > > transform
Return a new meta::list constructed by transforming all the elements in L with the unary invocable Fn...
Definition: meta.hpp:1852
transform.hpp

### Output

[0.5,1,1.5]

## Syntax

auto output_range = input_range | ranges::views::transform(transform_func);

## Parameters

    transform_func

- Maps an input value to an output value (`transform_func(T) -> U`)

    input_range

- The range of elements to transform
- Reference type: `T`

    output_range

- The range of output values
- Reference type: `U`
- Value type: `decay_t<U>`
- This range will have the same category as the input range (excluding contiguous ranges). Contiguous ranges are reduced to random access ranges.