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