Possible Duplicate:
How to write a `for` loop over bool values (false and true)
I want to perform the same task twice with bool flag
true first and false second. Is there an elegant way to do that (maybe using a loop)?
My idea was to do something like the following but this is a way too complicated.
bool flag = true;
for(int i = 0; i < 2; ++i, flag = !flag)
{
// ...
}