From Jason Turner

[dcl.struct.bind]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp69m_pg9p/{from.md → to.md} +23 -23
tmp/tmp69m_pg9p/{from.md → to.md} RENAMED
@@ -1,16 +1,16 @@
1
  ## Structured binding declarations <a id="dcl.struct.bind">[[dcl.struct.bind]]</a>
2
 
3
  A structured binding declaration introduces the *identifier*s `v₀`,
4
- `v₁`, `v₂`, … of the *identifier-list* as names
5
- [[basic.scope.declarative]] of *structured binding*s. Let cv denote the
6
- *cv-qualifier*s in the *decl-specifier-seq* and *S* consist of the
7
- *storage-class-specifier*s of the *decl-specifier-seq* (if any). A cv
8
- that includes `volatile` is deprecated; see  [[depr.volatile.type]].
9
- First, a variable with a unique name *`e`* is introduced. If the
10
- *assignment-expression* in the *initializer* has array type `A` and no
11
- *ref-qualifier* is present, *`e`* is defined by
12
 
13
  ``` bnf
14
  attribute-specifier-seqₒₚₜ *S* cv 'A' e ';'
15
  ```
16
 
@@ -32,11 +32,11 @@ from the corresponding structured binding declaration. The type of the
32
  If the *initializer* refers to one of the names introduced by the
33
  structured binding declaration, the program is ill-formed.
34
 
35
  If `E` is an array type with element type `T`, the number of elements in
36
  the *identifier-list* shall be equal to the number of elements of `E`.
37
- Each `v`ᵢ is the name of an lvalue that refers to the element i of the
38
  array and whose type is `T`; the referenced type is `T`.
39
 
40
  [*Note 2*: The top-level cv-qualifiers of `T` are cv. — *end note*]
41
 
42
  [*Example 1*:
@@ -52,18 +52,17 @@ auto& [ xr, yr ] = f(); // xr and yr refer to elements in the array refe
52
  Otherwise, if the *qualified-id* `std::tuple_size<E>` names a complete
53
  class type with a member named `value`, the expression
54
  `std::tuple_size<E>::value` shall be a well-formed integral constant
55
  expression and the number of elements in the *identifier-list* shall be
56
  equal to the value of that expression. Let `i` be an index prvalue of
57
- type `std::size_t` corresponding to `v`_`i`. The *unqualified-id* `get`
58
- is looked up in the scope of `E` by class member access lookup
59
- [[basic.lookup.classref]], and if that finds at least one declaration
60
- that is a function template whose first template parameter is a non-type
61
- parameter, the initializer is `e.get<i>()`. Otherwise, the initializer
62
- is `get<i>(e)`, where `get` is looked up in the associated namespaces
63
- [[basic.lookup.argdep]]. In either case, `get<i>` is interpreted as a
64
- *template-id*.
65
 
66
  [*Note 3*: Ordinary unqualified lookup [[basic.lookup.unqual]] is not
67
  performed. — *end note*]
68
 
69
  In either case, *`e`* is an lvalue if the type of the entity *`e`* is an
@@ -84,23 +83,24 @@ Otherwise, all of `E`’s non-static data members shall be direct members
84
  of `E` or of the same base class of `E`, well-formed when named as
85
  `e.name` in the context of the structured binding, `E` shall not have an
86
  anonymous union member, and the number of elements in the
87
  *identifier-list* shall be equal to the number of non-static data
88
  members of `E`. Designating the non-static data members of `E` as `m₀`,
89
- `m₁`, `m₂`, … (in declaration order), each `v`ᵢ is the name of an lvalue
90
- that refers to the member `m`ᵢ of *`e`* and whose type is cv `Tᵢ`, where
91
- `Tᵢ` is the declared type of that member; the referenced type is
92
- cv `Tᵢ`. The lvalue is a bit-field if that member is a bit-field.
 
93
 
94
  [*Example 2*:
95
 
96
  ``` cpp
97
- struct S { int x1 : 2; volatile double y1; };
98
  S f();
99
  const auto [ x, y ] = f();
100
  ```
101
 
102
- The type of the *id-expression* `x` is “`const int`”, the type of the
103
  *id-expression* `y` is “`const volatile double`”.
104
 
105
  — *end example*]
106
 
 
1
  ## Structured binding declarations <a id="dcl.struct.bind">[[dcl.struct.bind]]</a>
2
 
3
  A structured binding declaration introduces the *identifier*s `v₀`,
4
+ `v₁`, `v₂`, … of the *identifier-list* as names of *structured
5
+ binding*s. Let cv denote the *cv-qualifier*s in the *decl-specifier-seq*
6
+ and *S* consist of the *storage-class-specifier*s of the
7
+ *decl-specifier-seq* (if any). A cv that includes `volatile` is
8
+ deprecated; see  [[depr.volatile.type]]. First, a variable with a unique
9
+ name *`e`* is introduced. If the *assignment-expression* in the
10
+ *initializer* has array type *cv1* `A` and no *ref-qualifier* is
11
+ present, *`e`* is defined by
12
 
13
  ``` bnf
14
  attribute-specifier-seqₒₚₜ *S* cv 'A' e ';'
15
  ```
16
 
 
32
  If the *initializer* refers to one of the names introduced by the
33
  structured binding declaration, the program is ill-formed.
34
 
35
  If `E` is an array type with element type `T`, the number of elements in
36
  the *identifier-list* shall be equal to the number of elements of `E`.
37
+ Each `vᵢ` is the name of an lvalue that refers to the element i of the
38
  array and whose type is `T`; the referenced type is `T`.
39
 
40
  [*Note 2*: The top-level cv-qualifiers of `T` are cv. — *end note*]
41
 
42
  [*Example 1*:
 
52
  Otherwise, if the *qualified-id* `std::tuple_size<E>` names a complete
53
  class type with a member named `value`, the expression
54
  `std::tuple_size<E>::value` shall be a well-formed integral constant
55
  expression and the number of elements in the *identifier-list* shall be
56
  equal to the value of that expression. Let `i` be an index prvalue of
57
+ type `std::size_t` corresponding to `v`. If a search for the name `get`
58
+ in the scope of `E` [[class.member.lookup]] finds at least one
59
+ declaration that is a function template whose first template parameter
60
+ is a non-type parameter, the initializer is `e.get<i>()`. Otherwise, the
61
+ initializer is `get<i>(e)`, where `get` undergoes argument-dependent
62
+ lookup [[basic.lookup.argdep]]. In either case, `get<i>` is interpreted
63
+ as a *template-id*.
 
64
 
65
  [*Note 3*: Ordinary unqualified lookup [[basic.lookup.unqual]] is not
66
  performed. — *end note*]
67
 
68
  In either case, *`e`* is an lvalue if the type of the entity *`e`* is an
 
83
  of `E` or of the same base class of `E`, well-formed when named as
84
  `e.name` in the context of the structured binding, `E` shall not have an
85
  anonymous union member, and the number of elements in the
86
  *identifier-list* shall be equal to the number of non-static data
87
  members of `E`. Designating the non-static data members of `E` as `m₀`,
88
+ `m₁`, `m₂`, … (in declaration order), each `vᵢ` is the name of an lvalue
89
+ that refers to the member `m`ᵢ of *`e`* and whose type is that of `e.mᵢ`
90
+ [[expr.ref]]; the referenced type is the declared type of `mᵢ` if that
91
+ type is a reference type, or the type of `e.mᵢ` otherwise. The lvalue is
92
+ a bit-field if that member is a bit-field.
93
 
94
  [*Example 2*:
95
 
96
  ``` cpp
97
+ struct S { mutable int x1 : 2; volatile double y1; };
98
  S f();
99
  const auto [ x, y ] = f();
100
  ```
101
 
102
+ The type of the *id-expression* `x` is “`int`”, the type of the
103
  *id-expression* `y` is “`const volatile double`”.
104
 
105
  — *end example*]
106