24.4.2 Transformations - transform
(cont.)
- Second form takes 2 sequences, a binary function, and a
destination
- Applies function in pair-wise fashion
- Assumes 2nd sequence has at least as many elements
- Order of sources important (if function is not commutative)
- Target is c:
int add(int a, int b)
{
return a + b;
}
vector<int> c(10);
transform(a.begin(), a.end(), b.begin(),
c.begin(), add);
prev
|top
|next