|
46 | 46 |
|
47 | 47 | \Sec{Declarators}{Decl.Decl}
|
48 | 48 | \Sec{Initializers}{Decl.Init}
|
| 49 | + |
| 50 | +\p The process of initialization described in this section applies to all |
| 51 | +initializers regardless of the context. |
| 52 | + |
| 53 | +\begin{grammar} |
| 54 | + \define{initializer}\br |
| 55 | + brace-or-equal-initializer\br |
| 56 | + \terminal{(} expression-list \terminal{)}\br |
| 57 | + |
| 58 | + \define{brace-or-equal-initializer}\br |
| 59 | + \terminal{=} initializer-clause\br |
| 60 | + braced-init-list\br |
| 61 | + |
| 62 | + \define{initializer-clause}\br |
| 63 | + assignment-expression\br |
| 64 | + braced-init-list\br |
| 65 | + |
| 66 | + \define{braced-init-list}\br |
| 67 | + \terminal{\{} initializer-list \opt{\terminal{,}} \terminal{\}}\br |
| 68 | + \terminal{\{} \terminal{\}}\br |
| 69 | + |
| 70 | + \define{initializer-list}\br |
| 71 | + initializer-clause\br |
| 72 | + initializer-list \terminal{,} initializer-clause\br |
| 73 | +\end{grammar} |
| 74 | + |
| 75 | +\Sub{Aggregate Initialization}{Decl.Init.Agg} |
| 76 | + |
| 77 | +\p An \textit{aggregate} is a vector, matrix, array, or class. |
| 78 | + |
| 79 | +\p The subobjects of an aggregate have a defined order. For vectors and arrays |
| 80 | +the order is increasing subscript order. For matrices it is increasing subscript |
| 81 | +order with the subscript nesting such that in the notation |
| 82 | +\texttt{Mat[M][N]}, the ordering is \(Mat[0][0]...Mat[0][N]... |
| 83 | +Mat[M][0]...Mat[M][N]\). For classes the order is base class, followed by member |
| 84 | +subobjects in declaration order. |
| 85 | + |
| 86 | +\p A \textit{flattened ordering} of subobjects can be produced by performing a |
| 87 | +depth-first traversal of the subobjects of an object following the defined |
| 88 | +subobject ordering. |
| 89 | + |
| 90 | +\p Each \textit{braced initializer list} is comprised of zero or more |
| 91 | +\textit{initializer-clause} expressions, which is either another braced |
| 92 | +initializer list or an expression which generates a value that either is or can |
| 93 | +be implicitly converted to an rvalue. Each assignment-expression is an object, |
| 94 | +which may be a scalar or aggregate type. A \textit{flattened initializer |
| 95 | +sequence} is constructed by a depth-first traversal over each |
| 96 | +assignment-expression in an initializer-list and performing a depth-first |
| 97 | +traversal accessing each subobject of the assignment-expression. |
| 98 | + |
| 99 | +\p An initializer-list is a valid initializer if for each element \(E_n\) in the |
| 100 | +target object's flattened ordering there is a corresponding initializer \(I_n\) |
| 101 | +in the flattened initializer sequence which can be implicitly converted to the |
| 102 | +element's type. |
| 103 | + |
| 104 | +\p An initializer-list is invalid if the flattened initializer sequence contains |
| 105 | +more or fewer elements than the target object's flattened ordering, or if any |
| 106 | +initializer \(I_n\) cannot be implicitly converted to the corresponding element |
| 107 | +\(E_n\)'s type. |
| 108 | + |
49 | 109 | \Sec{Function Definitions}{Decl.Function}
|
50 | 110 | \Sec{Attributes}{Decl.Attr}
|
51 | 111 | \Sub{Semantic Annotations}{Decl.Attr.Semantic}
|
|
0 commit comments