tmp/tmpi_fe40_s/{from.md → to.md}
RENAMED
|
@@ -10,24 +10,10 @@ iteration-statement:
|
|
| 10 |
do statement while '(' expression ')' ';'
|
| 11 |
for '(' init-statement conditionₒₚₜ ';' expressionₒₚₜ ')' statement
|
| 12 |
for '(' init-statementₒₚₜ for-range-declaration ':' for-range-initializer ')' statement
|
| 13 |
```
|
| 14 |
|
| 15 |
-
``` bnf
|
| 16 |
-
for-range-declaration:
|
| 17 |
-
attribute-specifier-seqₒₚₜ decl-specifier-seq declarator
|
| 18 |
-
attribute-specifier-seqₒₚₜ decl-specifier-seq ref-qualifierₒₚₜ '[' identifier-list ']'
|
| 19 |
-
```
|
| 20 |
-
|
| 21 |
-
``` bnf
|
| 22 |
-
for-range-initializer:
|
| 23 |
-
expr-or-braced-init-list
|
| 24 |
-
```
|
| 25 |
-
|
| 26 |
-
See [[dcl.meaning]] for the optional *attribute-specifier-seq* in a
|
| 27 |
-
*for-range-declaration*.
|
| 28 |
-
|
| 29 |
[*Note 1*: An *init-statement* ends with a semicolon. — *end note*]
|
| 30 |
|
| 31 |
The substatement in an *iteration-statement* implicitly defines a block
|
| 32 |
scope [[basic.scope]] which is entered and exited each time through the
|
| 33 |
loop. If the substatement in an *iteration-statement* is a single
|
|
@@ -51,13 +37,39 @@ while (--x >= 0) {
|
|
| 51 |
|
| 52 |
Thus after the `while` statement, `i` is no longer in scope.
|
| 53 |
|
| 54 |
— *end example*]
|
| 55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
### The `while` statement <a id="stmt.while">[[stmt.while]]</a>
|
| 57 |
|
| 58 |
-
In the `while` statement the substatement is executed repeatedly until
|
| 59 |
the value of the condition [[stmt.pre]] becomes `false`. The test takes
|
| 60 |
place before each execution of the substatement.
|
| 61 |
|
| 62 |
A `while` statement is equivalent to
|
| 63 |
|
|
@@ -103,11 +115,11 @@ fails.
|
|
| 103 |
### The `do` statement <a id="stmt.do">[[stmt.do]]</a>
|
| 104 |
|
| 105 |
The expression is contextually converted to `bool` [[conv]]; if that
|
| 106 |
conversion is ill-formed, the program is ill-formed.
|
| 107 |
|
| 108 |
-
In the `do` statement the substatement is executed repeatedly until the
|
| 109 |
value of the expression becomes `false`. The test takes place after each
|
| 110 |
execution of the statement.
|
| 111 |
|
| 112 |
### The `for` statement <a id="stmt.for">[[stmt.for]]</a>
|
| 113 |
|
|
@@ -173,20 +185,20 @@ where
|
|
| 173 |
if it were surrounded by parentheses (so that a comma operator cannot
|
| 174 |
be reinterpreted as delimiting two *init-declarator*s);
|
| 175 |
- *`range`*, *`begin`*, and *`end`* are variables defined for exposition
|
| 176 |
only; and
|
| 177 |
- *`begin-expr`* and *`end-expr`* are determined as follows:
|
| 178 |
-
- if the *
|
| 179 |
*`begin-expr`* and *`end-expr`* are *`range`* and *`range`* `+` `N`,
|
| 180 |
respectively, where `N` is the array bound. If `R` is an array of
|
| 181 |
unknown bound or an array of incomplete type, the program is
|
| 182 |
ill-formed;
|
| 183 |
-
- if the *
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
- otherwise, *`begin-expr`* and *`end-expr`* are `begin(range)` and
|
| 189 |
`end(range)`, respectively, where `begin` and `end` undergo
|
| 190 |
argument-dependent lookup [[basic.lookup.argdep]].
|
| 191 |
\[*Note 1*: Ordinary unqualified lookup [[basic.lookup.unqual]] is
|
| 192 |
not performed. — *end note*]
|
|
@@ -219,9 +231,5 @@ void foo() {
|
|
| 219 |
}
|
| 220 |
```
|
| 221 |
|
| 222 |
— *end example*]
|
| 223 |
|
| 224 |
-
In the *decl-specifier-seq* of a *for-range-declaration*, each
|
| 225 |
-
*decl-specifier* shall be either a *type-specifier* or `constexpr`. The
|
| 226 |
-
*decl-specifier-seq* shall not define a class or enumeration.
|
| 227 |
-
|
|
|
|
| 10 |
do statement while '(' expression ')' ';'
|
| 11 |
for '(' init-statement conditionₒₚₜ ';' expressionₒₚₜ ')' statement
|
| 12 |
for '(' init-statementₒₚₜ for-range-declaration ':' for-range-initializer ')' statement
|
| 13 |
```
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
[*Note 1*: An *init-statement* ends with a semicolon. — *end note*]
|
| 16 |
|
| 17 |
The substatement in an *iteration-statement* implicitly defines a block
|
| 18 |
scope [[basic.scope]] which is entered and exited each time through the
|
| 19 |
loop. If the substatement in an *iteration-statement* is a single
|
|
|
|
| 37 |
|
| 38 |
Thus after the `while` statement, `i` is no longer in scope.
|
| 39 |
|
| 40 |
— *end example*]
|
| 41 |
|
| 42 |
+
A *trivially empty iteration statement* is an iteration statement
|
| 43 |
+
matching one of the following forms:
|
| 44 |
+
|
| 45 |
+
- `while (` *expression* `) ;`
|
| 46 |
+
- `while (` *expression* `) { }`
|
| 47 |
+
- `do ; while (` *expression* `) ;`
|
| 48 |
+
- `do { } while (` *expression* `) ;`
|
| 49 |
+
- `for (` *init-statement* *expression*ₒₚₜ `; ) ;`
|
| 50 |
+
- `for (` *init-statement* *expression*ₒₚₜ `; ) { }`
|
| 51 |
+
|
| 52 |
+
The *controlling expression* of a trivially empty iteration statement is
|
| 53 |
+
the *expression* of a `while`, `do`, or `for` statement (or `true`, if
|
| 54 |
+
the `for` statement has no *expression*). A *trivial infinite loop* is a
|
| 55 |
+
trivially empty iteration statement for which the converted controlling
|
| 56 |
+
expression is a constant expression, when interpreted as a
|
| 57 |
+
*constant-expression* [[expr.const]], and evaluates to `true`. The
|
| 58 |
+
*statement* of a trivial infinite loop is replaced with a call to the
|
| 59 |
+
function `std::this_thread::yield` [[thread.thread.this]]; it is
|
| 60 |
+
*implementation-defined* whether this replacement occurs on freestanding
|
| 61 |
+
implementations.
|
| 62 |
+
|
| 63 |
+
[*Note 2*: In a freestanding environment, concurrent forward progress
|
| 64 |
+
is not guaranteed; such systems therefore require explicit cooperation.
|
| 65 |
+
A call to yield can add implicit cooperation where none is otherwise
|
| 66 |
+
intended. — *end note*]
|
| 67 |
+
|
| 68 |
### The `while` statement <a id="stmt.while">[[stmt.while]]</a>
|
| 69 |
|
| 70 |
+
In the `while` statement, the substatement is executed repeatedly until
|
| 71 |
the value of the condition [[stmt.pre]] becomes `false`. The test takes
|
| 72 |
place before each execution of the substatement.
|
| 73 |
|
| 74 |
A `while` statement is equivalent to
|
| 75 |
|
|
|
|
| 115 |
### The `do` statement <a id="stmt.do">[[stmt.do]]</a>
|
| 116 |
|
| 117 |
The expression is contextually converted to `bool` [[conv]]; if that
|
| 118 |
conversion is ill-formed, the program is ill-formed.
|
| 119 |
|
| 120 |
+
In the `do` statement, the substatement is executed repeatedly until the
|
| 121 |
value of the expression becomes `false`. The test takes place after each
|
| 122 |
execution of the statement.
|
| 123 |
|
| 124 |
### The `for` statement <a id="stmt.for">[[stmt.for]]</a>
|
| 125 |
|
|
|
|
| 185 |
if it were surrounded by parentheses (so that a comma operator cannot
|
| 186 |
be reinterpreted as delimiting two *init-declarator*s);
|
| 187 |
- *`range`*, *`begin`*, and *`end`* are variables defined for exposition
|
| 188 |
only; and
|
| 189 |
- *`begin-expr`* and *`end-expr`* are determined as follows:
|
| 190 |
+
- if the type of *`range`* is a reference to an array type `R`,
|
| 191 |
*`begin-expr`* and *`end-expr`* are *`range`* and *`range`* `+` `N`,
|
| 192 |
respectively, where `N` is the array bound. If `R` is an array of
|
| 193 |
unknown bound or an array of incomplete type, the program is
|
| 194 |
ill-formed;
|
| 195 |
+
- if the type of *`range`* is a reference to a class type `C`, and
|
| 196 |
+
searches in the scope of `C` [[class.member.lookup]] for the names
|
| 197 |
+
`begin` and `end` each find at least one declaration, *`begin-expr`*
|
| 198 |
+
and *`end-expr`* are `range.begin()` and `range.end()`,
|
| 199 |
+
respectively;
|
| 200 |
- otherwise, *`begin-expr`* and *`end-expr`* are `begin(range)` and
|
| 201 |
`end(range)`, respectively, where `begin` and `end` undergo
|
| 202 |
argument-dependent lookup [[basic.lookup.argdep]].
|
| 203 |
\[*Note 1*: Ordinary unqualified lookup [[basic.lookup.unqual]] is
|
| 204 |
not performed. — *end note*]
|
|
|
|
| 231 |
}
|
| 232 |
```
|
| 233 |
|
| 234 |
— *end example*]
|
| 235 |
|
|
|
|
|
|
|
|
|
|
|
|