D
Diego Martins
Hi!
Often, I have some situations when I have to convert a vector of 10
elements to a vector of 30 elements or vice-versa. (the ratio is 1-3)
I want to use the std::transform do to these tasks, but I end up using
std::for_each
Is a special/custom iterator the only way to do that with
std::transform?
Example:
vector<int> source, destiny;
....
now source has 30 elements
destiny.resize(10);
transform(source.begin(),source.end(),destiny.begin(),ThreeToOneConverter());
** how to write the ThreeToOneConverter functor in order to process and
skip three elements at a time instead of one?
Another example:
vector<int> source, destiny;
....
now source has 10 elements
destiny.resize(30);
transform(source.begin(),source.end(),ThreeAtRowIterator(destiny),OneToThreeConverter());
it will generate more abominations
Only for_each is the solution to this case?
Diego Martins
HP
Often, I have some situations when I have to convert a vector of 10
elements to a vector of 30 elements or vice-versa. (the ratio is 1-3)
I want to use the std::transform do to these tasks, but I end up using
std::for_each
Is a special/custom iterator the only way to do that with
std::transform?
Example:
vector<int> source, destiny;
....
now source has 30 elements
destiny.resize(10);
transform(source.begin(),source.end(),destiny.begin(),ThreeToOneConverter());
** how to write the ThreeToOneConverter functor in order to process and
skip three elements at a time instead of one?
Another example:
vector<int> source, destiny;
....
now source has 10 elements
destiny.resize(30);
transform(source.begin(),source.end(),ThreeAtRowIterator(destiny),OneToThreeConverter());
it will generate more abominations
Only for_each is the solution to this case?
Diego Martins
HP