From Jason Turner

[stmt.iter.general]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp840ooj3z/{from.md → to.md} +53 -0
tmp/tmp840ooj3z/{from.md → to.md} RENAMED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### General <a id="stmt.iter.general">[[stmt.iter.general]]</a>
2
+
3
+ Iteration statements specify looping.
4
+
5
+ ``` bnf
6
+ iteration-statement:
7
+ while '(' condition ')' statement
8
+ do statement while '(' expression ')' ';'
9
+ for '(' init-statement conditionₒₚₜ ';' expressionₒₚₜ ')' statement
10
+ for '(' init-statementₒₚₜ for-range-declaration ':' for-range-initializer ')' statement
11
+ ```
12
+
13
+ ``` bnf
14
+ for-range-declaration:
15
+ attribute-specifier-seqₒₚₜ decl-specifier-seq declarator
16
+ attribute-specifier-seqₒₚₜ decl-specifier-seq ref-qualifierₒₚₜ '[' identifier-list ']'
17
+ ```
18
+
19
+ ``` bnf
20
+ for-range-initializer:
21
+ expr-or-braced-init-list
22
+ ```
23
+
24
+ See  [[dcl.meaning]] for the optional *attribute-specifier-seq* in a
25
+ *for-range-declaration*.
26
+
27
+ [*Note 1*: An *init-statement* ends with a semicolon. — *end note*]
28
+
29
+ The substatement in an *iteration-statement* implicitly defines a block
30
+ scope [[basic.scope]] which is entered and exited each time through the
31
+ loop. If the substatement in an *iteration-statement* is a single
32
+ statement and not a *compound-statement*, it is as if it was rewritten
33
+ to be a *compound-statement* containing the original statement.
34
+
35
+ [*Example 1*:
36
+
37
+ ``` cpp
38
+ while (--x >= 0)
39
+ int i;
40
+ ```
41
+
42
+ can be equivalently rewritten as
43
+
44
+ ``` cpp
45
+ while (--x >= 0) {
46
+ int i;
47
+ }
48
+ ```
49
+
50
+ Thus after the `while` statement, `i` is no longer in scope.
51
+
52
+ — *end example*]
53
+