|
543 | 543 | int i;
|
544 | 544 | }
|
545 | 545 | \end{codeblock}
|
| 546 | + |
546 | 547 | Thus after the \keyword{while} statement, \tcode{i} is no longer in scope.
|
547 | 548 | \end{example}
|
548 | 549 |
|
| 550 | +\pnum |
| 551 | +A \defnadj{trivially empty}{ iteration statement} is |
| 552 | +an iteration statement matching one of the following forms: |
| 553 | +\begin{itemize} |
| 554 | +\item \tcode{while (} \grammarterm{expression} \tcode{) ;} |
| 555 | +\item \tcode{while (} \grammarterm{expression} \tcode{) \{ \}} |
| 556 | +\item \tcode{do ; while (} \grammarterm{expression} \tcode{) ;} |
| 557 | +\item \tcode{do \{ \} while (} \grammarterm{expression} \tcode{) ;} |
| 558 | +\item \tcode{for (} \grammarterm{init-statement} \opt{\grammarterm{expression}} \tcode{; ) ;} |
| 559 | +\item \tcode{for (} \grammarterm{init-statement} \opt{\grammarterm{expression}} \tcode{; ) \{ \}} |
| 560 | +\end{itemize} |
| 561 | +The \defnadj{controlling}{expression} of a trivially empty iteration statement |
| 562 | +is the \grammarterm{expression} of |
| 563 | +a \tcode{while}, \tcode{do}, or \tcode{for} statement |
| 564 | +(or \tcode{true}, if the \tcode{for} statement has no \grammarterm{expression}). |
| 565 | +A \defnadj{trivial infinite}{loop} is a trivially empty iteration statement |
| 566 | +for which the converted controlling expression is a constant expression, |
| 567 | +when interpreted as a \grammarterm{constant-expression}\iref{expr.const}, and |
| 568 | +evaluates to \tcode{true}. |
| 569 | +The \grammarterm{statement} of a trivial infinite loop is replaced with |
| 570 | +a call to the function \tcode{std::this_thread::yield}\iref{thread.thread.this}; |
| 571 | +it is implementation-defined whether this replacement occurs |
| 572 | +on freestanding implementations. |
| 573 | +\begin{note} |
| 574 | +In a freestanding environment, |
| 575 | +concurrent forward progress is not guaranteed; |
| 576 | +such systems therefore require explicit cooperation. |
| 577 | +A call to yield can add implicit cooperation where none is otherwise intended. |
| 578 | +\end{note} |
| 579 | + |
549 | 580 | \rSec2[stmt.while]{The \keyword{while} statement}%
|
550 | 581 | \indextext{statement!\idxcode{while}}
|
551 | 582 |
|
|
0 commit comments