Difference between revisions of "cpp/algorithm/transform"
From cppreference.com
m (→Parameters: use link to synopsis.) |
|||
(80 intermediate revisions by 27 users not shown) | |||
Line 1: | Line 1: | ||
{{cpp/title|transform}} | {{cpp/title|transform}} | ||
− | {{cpp/algorithm/ | + | {{cpp/algorithm/}} |
− | {{ | + | {{begin}} |
− | {{ | + | {{header|algorithm}} |
− | {{ | + | {{|num=1| |
− | template< class | + | template< class , class , class > |
− | + | transform( first1, last1, | |
− | + | d_first, unary_op ); | |
}} | }} | ||
− | {{ | + | {{|num=2| |
− | template< class | + | template< class , |
− | + | class , class , class > | |
− | + | transform( | |
+ | first1, last1, | ||
+ | d_first, ); | ||
}} | }} | ||
− | {{ | + | {{ |
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | end}} | ||
− | + | {{tt|}} the to the range, the from {{|}}. | |
− | + | {{}} {{|first1last1}} | |
− | {{ | + | {{|}} of the |
− | {{ | + | {{||}} |
− | + | {{|}} {{}} | |
− | {{ | + | |
− | + | ||
− | {{ | + | |
− | {{ | + | |
− | {{ | + | |
− | + | ||
− | {{ | + | |
+ | |||
+ | |||
+ | {{}} | ||
− | + | to . | |
+ | |||
− | + | ====== | |
− | {{ | + | |
− | {{ | + | = |
− | + | ||
− | template<class | + | |
− | + | ||
− | + | = | |
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | - | ||
+ | - | ||
+ | {{}} | ||
+ | |||
+ | |||
+ | {{cpp | ||
+ | |||
+ | |||
+ | |||
+ | |1= | ||
+ | template<class , class , class > | ||
+ | |||
+ | (first1, last1, | ||
+ | d_first, unary_op) | ||
{ | { | ||
− | + | (first1 != last1) | |
− | *d_first | + | *d_first = unary_op(*first1); |
− | + | ||
return d_first; | return d_first; | ||
} | } | ||
− | + | |2= | |
− | template<class | + | template<class , class , |
− | + | class , class > | |
− | + | ||
+ | (first1, last1, first2, | ||
+ | d_first, binary_op) | ||
{ | { | ||
− | + | (first1 != last1) | |
− | *d_first | + | *d_first = binary_op(*first1, *first2); |
− | + | ||
return d_first; | return d_first; | ||
} | } | ||
}} | }} | ||
− | + | ====== | |
− | {{ | + | {{}} |