I have a vector of elements which I iterate through and call a method
on each of the elements. I want to do it using std::for_each
algorithm, but having a problem implementing it since the method that
I call on each element takes an argument and I don't know how to pass
this argument through. Here is the code using an old fashioned loop:
.......
std::vector<uns igned char bytes;
std::vector<Tel ements;
....
for (int i = 0; i < elements.size() ; ++i) {
elements[i].serialize(byte s);
}
..........
could someone please help me out rewrite that using std::for_each?
Thanks!
on each of the elements. I want to do it using std::for_each
algorithm, but having a problem implementing it since the method that
I call on each element takes an argument and I don't know how to pass
this argument through. Here is the code using an old fashioned loop:
.......
std::vector<uns igned char bytes;
std::vector<Tel ements;
....
for (int i = 0; i < elements.size() ; ++i) {
elements[i].serialize(byte s);
}
..........
could someone please help me out rewrite that using std::for_each?
Thanks!
Comment