I have a function func which returns true or false. Until func returns false, I want to keep calling it. What is the least awkward way to do this?
do {
// do nothing
} while (func());
or..
while (func());
or..
while (func())
if (!func())
break;
All of them look really awkward and unintuitive to me. Is there another solution to this altogether?
I think option B is most commonly used, but you should make it more obvious that you have an empty loop body:
or
As a side note, this looks like some kind of busy waiting. If this is the case, it can and should usually be avoided by using OS-provided synchronization primitives.