I have an std::vector
of objects. For each object in the vector, I want to modify the value of an object member. The following thoughts came into my mind:
If I had a vector of primitives, I would use
std::fill
to do that. However, I cannot imagine how to applystd::fill
to a vector of objects.I know that I could definitely iterate over all objects using an iterator but that is much code for a tiny task.
What is the best way to modify the value of an object member for all objects in std::vector
?