|
475 | 475 |
|
476 | 476 | except that names declared in the \grammarterm{for-init-statement} are in
|
477 | 477 | the same declarative region as those declared in the
|
478 |
| -\grammarterm{}{condition}, and except that a |
| 478 | +\grammarterm{condition}, and except that a |
479 | 479 | \indextext{statement!\tcode{continue}~in \tcode{for}}%
|
480 |
| -\tcode{continue} in \grammarterm{}{statement} (not enclosed in another |
481 |
| -iteration statement) will execute \grammarterm{}{expression} before |
482 |
| -re-evaluating \grammarterm{}{condition}. |
| 480 | +\tcode{continue} in \grammarterm{statement} (not enclosed in another |
| 481 | +iteration statement) will execute \grammarterm{expression} before |
| 482 | +re-evaluating \grammarterm{condition}. |
483 | 483 | \enternote
|
484 | 484 | Thus the first statement specifies initialization for the loop; the
|
485 | 485 | condition~(\ref{stmt.select}) specifies a test, sequenced before each
|
|
489 | 489 | \exitnote
|
490 | 490 |
|
491 | 491 | \pnum
|
492 |
| -Either or both of the condition and the expression can be omitted. A |
493 |
| -missing \grammarterm{}{condition} makes the implied \tcode{while} clause |
| 492 | +Either or both of the \grammarterm{condition} |
| 493 | +and the \grammarterm{expression} can be omitted. |
| 494 | +A missing \grammarterm{condition} |
| 495 | +makes the implied \tcode{while} clause |
494 | 496 | equivalent to \tcode{while(true)}.
|
495 | 497 |
|
496 | 498 | \pnum
|
|
515 | 517 | \indextext{statement!range~based \idxcode{for}}
|
516 | 518 |
|
517 | 519 | \pnum
|
518 |
| -A range-based \tcode{for} statement is equivalent to |
| 520 | +The range-based \tcode{for} statement |
519 | 521 |
|
520 |
| -\begin{codeblock} |
521 |
| -{ |
522 |
| - auto && __range = @\grammarterm{for-range-initializer}@; |
523 |
| - for ( auto __begin = begin-expr, |
524 |
| - __end = end-expr; |
525 |
| - __begin != __end; |
526 |
| - ++__begin ) { |
527 |
| - @\grammarterm{for-range-declaration}@ = *__begin; |
528 |
| - @\grammarterm{statement}@ |
529 |
| - } |
530 |
| -} |
531 |
| -\end{codeblock} |
| 522 | +\begin{ncbnf} |
| 523 | +\terminal{for (} for-range-declaration \terminal{:} for-range-initializer \terminal{)} statement |
| 524 | +\end{ncbnf} |
| 525 | + |
| 526 | +is equivalent to |
| 527 | + |
| 528 | +\begin{ncbnftab} |
| 529 | +\terminal{\{}\br |
| 530 | +\>\terminal{auto \&\&__range =} for-range-initializer \terminal{;}\br |
| 531 | +\>\terminal{for ( auto __begin =} begin-expr \terminal{,}\br |
| 532 | +\>\terminal{ \ \ \ \ \ \ \ \ \ \ __end =} end-expr \terminal{;}\br |
| 533 | +\>\terminal{ \ \ \ \ \ __begin != __end;}\br |
| 534 | +\>\terminal{ \ \ \ \ \ ++__begin ) \{}\br |
| 535 | +\>\>for-range-declaration \terminal{= *__begin;}\br |
| 536 | +\>\>statement\br |
| 537 | +\>\terminal{\}}\br |
| 538 | +\terminal{\}} |
| 539 | +\end{ncbnftab} |
532 | 540 |
|
533 | 541 | where
|
534 | 542 |
|
|
0 commit comments