dimanche 7 janvier 2018

Using a lambda with std::advance along with std::for_each()

I need to use std::for_each() to iterate through a list. However, in the UnaryFunction part of for_each(), I need to use a lambda which actually advances the iterator by means of std::advance().

For instance

for_each(beginIter, endIter, lambda);

and

auto lambda [] = (<Iter parameter>){advance(Iter parameter, 1)};

I am expecting that when the lambda returns, the for_each() would resume iterating from the position where the lambda left off.

Is this understanding correct?

TIA

Vinod

Aucun commentaire:

Enregistrer un commentaire