jeudi 21 juillet 2016

C++11 for each loop with more than one variable

I would like to translate the following traditional for loop into a C++11 for-each loop without extra looping constructs:

int a[] = { 5, 6, 7, 8, 9, 10 };
int a[] = { 5, 6, 7, 8, 9, 10 };

for (int i = 0; i < sizeof(a)/sizeof(a[0]); i++)
{
   a[i] ^= b[i]; b[i] ^= a[i]; a[i] ^= b[i];
}

Does there exist any way by which it is possible to provide more than one variable in the C++11 for-each loop like:

for (int i, int j : ...)

Aucun commentaire:

Enregistrer un commentaire