conversion (test.begin (), test.end (), test.begin (), (-1 + = Var (a), ++ Var (a)));
This will translate to
int doit(int & elem) { elem += a; return ++a; } for each elem : elem = doit(elem);
Starting with a = 0, the result will be 1 in the first run. We increase 10 times, so in the last run we get 10.
for_each (test.begin (), test.end (), (_ 1 + = Var (a), ++ Var (a)));
This will translate to
void doit(int & elem) { elem += a; ++a; } for each elem : doit(elem);
Starting at a = 0, we get 0 in the first run. We increase 10 times, but assign it immediately before the increment. So the last number is 9.
Hopefully itβs now clear that the translation into the usual functions is what these two do.
source share