J
jalina
Is there a way to get the current iteration in a for_each loop ?
For example:
void f(int val)
{
// Here how get the current
// index or iterator that get called
// by the for_each loop ?
}
void g()
{
list<int> l;
// ...put some value in l
for_each(l.begin(), l.end(), f);
}
I guess f() has no way to know that is being called in a for_each. So
should I stick to a basic loop to do that or is there a trick ?
Tnx,
J.
For example:
void f(int val)
{
// Here how get the current
// index or iterator that get called
// by the for_each loop ?
}
void g()
{
list<int> l;
// ...put some value in l
for_each(l.begin(), l.end(), f);
}
I guess f() has no way to know that is being called in a for_each. So
should I stick to a basic loop to do that or is there a trick ?
Tnx,
J.