C
cppaddict
Hi,
I need to a way to loop thru vectors (or some other appropriate collection
type)
using constructs such as:
for (pr = someVector.begin(); pr != someVector.end(); pr++)
SomeFunction(*pr);
OR
for_each(someVector.begin(), someVector.end(), SomeFunction);
The problem is, I want SomeFunction to be able to add to the vector as it's
being looped over. Simply adding to the vector as it's being looped,
however,
produces strange results. But I know there must be *some* easy way to do
what I
want. Does anyone know what it is?
Thanks,
cpp
I need to a way to loop thru vectors (or some other appropriate collection
type)
using constructs such as:
for (pr = someVector.begin(); pr != someVector.end(); pr++)
SomeFunction(*pr);
OR
for_each(someVector.begin(), someVector.end(), SomeFunction);
The problem is, I want SomeFunction to be able to add to the vector as it's
being looped over. Simply adding to the vector as it's being looped,
however,
produces strange results. But I know there must be *some* easy way to do
what I
want. Does anyone know what it is?
Thanks,
cpp