mirror of
https://gitlab.com/fbb-git/cppannotations
synced 2024-11-16 07:48:44 +01:00
45 lines
1.9 KiB
Text
45 lines
1.9 KiB
Text
hi(transform)
|
|
itemization(
|
|
it() Header file: tt(<algorithm>)
|
|
it() Function prototypes:
|
|
itemization(
|
|
itt(OutputIterator transform(InputIterator first, InputIterator
|
|
last, OutputIterator result, UnaryOperator op);)
|
|
itt(OutputIterator transform(InputIterator1 first1, InputIterator1
|
|
last1, InputIterator2 first2, OutputIterator result, BinaryOperator op);)
|
|
)
|
|
it() Description:
|
|
itemization(
|
|
it() The first prototype: the unary operator tt(op) is applied to
|
|
each of the elements in the range rangett(first, last), and the resulting
|
|
values are stored in the range starting at tt(result). The return value points
|
|
just beyond the last generated element.
|
|
it() The second prototype: the binary operator tt(op) is applied
|
|
to each of the elements in the range rangett(first1, last1) and the
|
|
corresponding element in the second range starting at tt(first2). The
|
|
resulting values are stored in the range starting at tt(result). The return
|
|
value points just beyond the last generated element.
|
|
)
|
|
it() Example:
|
|
verbinclude(-a examples/transform.cc)
|
|
)
|
|
the following differences between the tt(for_each) (section
|
|
ref(FOREACH)) and tt(transform) generic algorithms should be noted:
|
|
hi(for_each: vs. transform)hi(transform: vs. for_each)
|
|
itemization(
|
|
it() With tt(transform) the em(return value) of the function
|
|
object's tt(operator()) member is used; the argument that is passed to the
|
|
tt(operator()) member itself is not changed.
|
|
it() With tt(for_each) the function object's tt(operator())
|
|
receives a reference to an argument, which itself may be changed by the
|
|
function object's tt(operator()).
|
|
)
|
|
Also note that the range-based for loop can often be used instead of the
|
|
tt(transform) generic algorithm. However, but different from the
|
|
range-based for-loop the tt(transform) algoritm can also be used width
|
|
sub-ranges and with reverse-iterators.
|
|
|
|
|
|
|
|
|
|
|