From Jason Turner

[stmt.ranged]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp3rukafe_/{from.md → to.md} +27 -14
tmp/tmp3rukafe_/{from.md → to.md} RENAMED
@@ -1,39 +1,52 @@
1
  ### The range-based `for` statement <a id="stmt.ranged">[[stmt.ranged]]</a>
2
 
3
  The range-based `for` statement
4
 
5
  ``` bnf
6
- 'for (' for-range-declaration ':' for-range-initializer ')' statement
7
  ```
8
 
9
  is equivalent to
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  where
12
 
13
  - if the *for-range-initializer* is an *expression*, it is regarded as
14
  if it were surrounded by parentheses (so that a comma operator cannot
15
  be reinterpreted as delimiting two *init-declarator*s);
16
- - `__range`, `__begin`, and `__end` are variables defined for exposition
17
  only; and
18
  - *begin-expr* and *end-expr* are determined as follows:
19
  - if the *for-range-initializer* is an expression of array type `R`,
20
- *begin-expr* and *end-expr* are `__range` and `__range + __bound`,
21
- respectively, where `__bound` is the array bound. If `R` is an array
22
- of unknown bound or an array of incomplete type, the program is
23
  ill-formed;
24
  - if the *for-range-initializer* is an expression of class type `C`,
25
  the *unqualified-id*s `begin` and `end` are looked up in the scope
26
- of `C` as if by class member access lookup (
27
- [[basic.lookup.classref]]), and if either (or both) finds at least
28
- one declaration, *begin-expr* and *end-expr* are `__range.begin()`
29
- and `__range.end()`, respectively;
30
- - otherwise, *begin-expr* and *end-expr* are `begin(__range)` and
31
- `end(__range)`, respectively, where `begin` and `end` are looked up
32
- in the associated namespaces ([[basic.lookup.argdep]]).
33
- \[*Note 1*: Ordinary unqualified lookup ([[basic.lookup.unqual]])
34
- is not performed. — *end note*]
35
 
36
  [*Example 1*:
37
 
38
  ``` cpp
39
  int array[5] = { 1, 2, 3, 4, 5 };
 
1
  ### The range-based `for` statement <a id="stmt.ranged">[[stmt.ranged]]</a>
2
 
3
  The range-based `for` statement
4
 
5
  ``` bnf
6
+ for '(' init-statementₒₚₜ for-range-declaration ':' for-range-initializer ')' statement
7
  ```
8
 
9
  is equivalent to
10
 
11
+ ``` bnf
12
+ '{'
13
+ init-statementₒₚₜ
14
+ auto '&&'range '=' for-range-initializer ';'
15
+ auto begin '=' begin-expr ';'
16
+ auto end '=' end-expr ';'
17
+ for '(' ';' begin '!=' end';' '++'begin ')' '{'
18
+ for-range-declaration '=' '*' begin ';'
19
+ statement
20
+ '}'
21
+ '}'
22
+ ```
23
+
24
  where
25
 
26
  - if the *for-range-initializer* is an *expression*, it is regarded as
27
  if it were surrounded by parentheses (so that a comma operator cannot
28
  be reinterpreted as delimiting two *init-declarator*s);
29
+ - *`range`*, *`begin`*, and *`end`* are variables defined for exposition
30
  only; and
31
  - *begin-expr* and *end-expr* are determined as follows:
32
  - if the *for-range-initializer* is an expression of array type `R`,
33
+ *begin-expr* and *end-expr* are *`range`* and *`range`* `+` `N`,
34
+ respectively, where `N` is the array bound. If `R` is an array of
35
+ unknown bound or an array of incomplete type, the program is
36
  ill-formed;
37
  - if the *for-range-initializer* is an expression of class type `C`,
38
  the *unqualified-id*s `begin` and `end` are looked up in the scope
39
+ of `C` as if by class member access lookup
40
+ [[basic.lookup.classref]], and if both find at least one
41
+ declaration, *begin-expr* and *end-expr* are `range.begin()` and
42
+ `range.end()`, respectively;
43
+ - otherwise, *begin-expr* and *end-expr* are `begin(range)` and
44
+ `end(range)`, respectively, where `begin` and `end` are looked up in
45
+ the associated namespaces [[basic.lookup.argdep]].
46
+ \[*Note 1*: Ordinary unqualified lookup [[basic.lookup.unqual]] is
47
+ not performed. — *end note*]
48
 
49
  [*Example 1*:
50
 
51
  ``` cpp
52
  int array[5] = { 1, 2, 3, 4, 5 };