|
A loop is intended to express repetition. If it is not possible to perform a loop's body more than once, then no repetition is possible.
Look at the following example, which uses a predicate p that is presumably defined elsewhere.
bool example(const int n) { int k = 1; while(k <= n) { if(p(k)) { return true; } else { return false; } } }Notice that the loop body returns no matter what. Since a return-statement ends the function call, it is not possible to do the body more than once. The standards forbid that sort of loop body.
|