A
alan.patterson5
I have a vector of N values and a vector of N functors. I want to apply
each functor to its corresponding value. What would be the 'correct'
STL way to do this.
for_each takes on functor and applies it to every element.
So presumably transform is a better option but it also takes one
functor.
This is obviously easily solved by a variety of methods but I am
interested in how the STL would best solve this problem.
e.g.
// fill vector with some values
vector<int> x (values.begin(), values.end());
vector<functor> funcs;
// fill funcs with different functors, or functors with different
parameters
// would like to do STL equivalent of
for (int i=0; i<x.size(); ++i) {
funcs(x);
}
each functor to its corresponding value. What would be the 'correct'
STL way to do this.
for_each takes on functor and applies it to every element.
So presumably transform is a better option but it also takes one
functor.
This is obviously easily solved by a variety of methods but I am
interested in how the STL would best solve this problem.
e.g.
// fill vector with some values
vector<int> x (values.begin(), values.end());
vector<functor> funcs;
// fill funcs with different functors, or functors with different
parameters
// would like to do STL equivalent of
for (int i=0; i<x.size(); ++i) {
funcs(x);
}