You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Braces can be elided in an initializer-list as follows. If the initializer-list begins with a left brace, then the succeeding comma-separated list of initializer-clauses initializes the elements of a subaggregate;
Presumably, the initializer-list refers to the initializer-list enclosed in the brace-list-initializer of the aggregate initialization. Consider this example:
structA{
int a;
};
structB{
int arr[2];
A obj;
};
intmain(){
B b = {0,1,{2}}; // #1
B b2 = {{0,1},2}; //#2
}
In this case, the initializer-list at #1 is 0,1,{2} that does not begin with a left brace.
If, however, the initializer-list for a subaggregate does not begin with a left brace, then only enough initializer-clauses from the list are taken to initialize the elements of the subaggregate;
The initializer-list at #2 is {0,1}, 2 that does begin with a left brace, however, we want the brace elision rule can apply to the initializer-clause 2 when initializing the subaggregate B::obj. In such two cases, we just intend to mean whether the initializer-clause begins with a left brace or not.
Maybe, change [dcl.init.aggr] p16 to
Braces can be elided in an initializer-list as follows. If the initializer-clause in the initializer-list that would initialize the subaggregate element is not a braced-init-list, only enough initializer-clauses from the list are taken to initialize the elements of the subaggregate; the elements are considered to be explicitly initialized. Any remaining initializer-clauses(if any) are left to initialize the next element of the aggregate of which the current subaggregate is an element.
if the initializer-clause is a brace-init-list, I think it is not necessary to specify in this paragraph. That would be redundant since it is just a normal aggregate initialization.
The emphasized wording may be more precise if it is changed to
If the initializer-clause in the initializer-list that would initialize the subaggregate element is not a braced-init-list, only enough initializer-clauses from the list are taken with comma-separation to form an initializer-list D, the subaggregate is initialized by braced-init-list { D }
The text was updated successfully, but these errors were encountered:
[dcl.init.aggr] p16 state
Presumably, the initializer-list refers to the initializer-list enclosed in the brace-list-initializer of the aggregate initialization. Consider this example:
In this case, the initializer-list at
#1
is0,1,{2}
that does not begin with a left brace.The initializer-list at
#2
is{0,1}, 2
that does begin with a left brace, however, we want the brace elision rule can apply to the initializer-clause2
when initializing the subaggregateB::obj
. In such two cases, we just intend to mean whether the initializer-clause begins with a left brace or not.Maybe, change [dcl.init.aggr] p16 to
if the initializer-clause is a brace-init-list, I think it is not necessary to specify in this paragraph. That would be redundant since it is just a normal aggregate initialization.
The emphasized wording may be more precise if it is changed to
The text was updated successfully, but these errors were encountered: