The canonical form allows the iteration count of all associated loops to be computed before executing the outermost loop.
So should it allow for(int i = 0; i != 10; i++) for example? we know before hand that will be 10 iterations.
The for directive places restrictions on the structure of all associated for-loops.
Specifically, all associated for-loops must have the following canonical form:
for (init-expr; test-expr; incr-expr) structured-block
init-expr One of the following:
var = lb
integer-type var = lb
random-access-iterator-type var = lb
pointer-type var = lb
test-expr One of the following:
var relational-op b
b relational-op var
incr-expr One of the following:
var += incr
var -= incr
var = var + incr
var = incr + var
var = var - incr
var One of the following:
A variable of a signed or unsigned integer type.
For C++, a variable of a random access iterator type.
For C, a variable of a pointer type.
If this variable would otherwise be shared, it is implicitly made
private in the loop construct. This variable must not be
modified during the execution of the for-loop other than in
incr-expr. Unless the variable is specified lastprivate on
the loop construct, its value after the loop is unspecified.
relational-op One of the following:
lb and b Loop invariant expressions of a type compatible with the type
incr A loop invariant integer expression.
Users browsing this forum: No registered users and 4 guests