I have two vectors.
vector<Object> objects;
vector<string> names;
These two vectors are populated and have the same size. I need some algorithm which does assignment to the object variable. It could be using boost::lambda. Let's say:
some_algoritm(objects.begin(), objects.end(), names.begin(), bind(&Object::Name, _1) = _2);
Any suggestion?
I think that you want
std::for_each
because eachObject
instance is being modified in-place:Here is a complete, compilable example:
Outputs:
I can't think of a
std::
algorithm for this. But, you can always write your own:EDIT: Another alternative, if you are able to define
operator=
appropriately, isstd::copy
: