Is there a function like std::for_each that directly passes the iterators instead of the result of dereferencing them?
What we have
std::vector<int> ints;
std::for_each(ints.begin(), ints.end(),
[](int i)
{
//how to get the iterator of this element???
}
what I am searching for
for_each_iterator(ints.begin(), ints.end(),
[](const std::vector<int>::const_iterator &i)
{
//we know the iterator here
}
Of course it is fairly trivial to write such a function, but I am asking if there exists a standard solution from std::, std::tr1:: or boost::
There is no such thing in the Standard library. But it is not that hard to implement it yourself:
And use it as:
Or use manual loop.