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
In addition, if C is defined and its definition satisfies the conditions for an aggregate class ([dcl.init.aggr]) with the assumption that any dependent base class has no virtual functions and no virtual base classes, and the initializer is a non-empty braced-init-list or parenthesized expression-list, and there are no deduction-guides for C, the set contains an additional function template, called the aggregate deduction candidate, defined as follows. Let X1,...,XN be the elements of the initializer-list or designated-initializer-list of the braced-init-list, or of the expression-list. For each Xi, let ei be the corresponding aggregate element of C or of one of its (possibly recursive) subaggregates that would be initialized by Xi if
[1.5] brace elision is not considered for any aggregate element that has a dependent non-array type or an array type with a value-dependent bound, and
[1.6] each non-trailing aggregate element that is a pack expansion is assumed to correspond to no elements of the initializer list, and
[1.7] a trailing aggregate element that is a pack expansion is assumed to correspond to all remaining elements of the initializer list (if any).
If there is no such aggregate element ei for any Xi, the aggregate deduction candidate is not added to the set. The aggregate deduction candidate is derived as above from a hypothetical constructor C(T1,...,Tn)
if ei is of array type and xi is a braced-init-list or string-literal, Ti is an rvalue reference to the declared type of ei
otherwise, Ti is the declared type of ei
According to the expound in P2082R1 and the following example, the actual intent seems to be that:
ei is the corresponding aggregate element of C if the aggregate element is a dependent non-array type or an array type with a value-dependent bound. Instead, ei is the corresponding aggregate element of one of C's subaggregates if the brace elision can be considered(i.e, the inverse cases of what the previous sentence says). However, the current appearance of the structure of "if..." seems to have a reverse meaning. Specifically, the rule probably can be read as that
let ei be the corresponding aggregate element of C,
or the corresponding aggregate element one of its (possibly recursive) subaggregates that would be initialized by Xi if
[1.5] brace elision is not considered for any aggregate element that has a dependent non-array type or an array type with a value-dependent bound
[...]
See this example
template<typename T>
structTest{
T t[2];
};
intmain(){
Test t{{1,2}};
}
According to the diagnosis of GCC, the candidate set comprises template<class T> Test(T, T)-> Test<T>. The obscure structure can result in this issue.
Issue 2:
Notice the bullet [1.6] and [1.7] in the above rule. It appears to me these bullets should be statements(general rules for aggregate CTAD), why are they placed after the if condition?
The text was updated successfully, but these errors were encountered:
jensmaurer
changed the title
The obscure structure of the rule for aggregate deduction
[over.match.class.deduct] The obscure structure of the rule for aggregate deduction
Jul 9, 2021
From the response of the mailing this issue to core language issue, the intent of this rule is saying if the type of the aggregate element is neither a dependent non-array type nor an array type with a value-dependent bound, and the brace elision is considered due to the initializer-list does not begin with a left brace, ei is the corresponding aggregate element of the subaggregate, otherwise, it is the aggregate element. But, such meaning is hard to read from the current wording(structure).
According to the expound in P2082R1 and the following example, the actual intent seems to be that:
ei is the corresponding aggregate element of C if the aggregate element is a dependent non-array type or an array type with a value-dependent bound. Instead, ei is the corresponding aggregate element of one of C's subaggregates if the brace elision can be considered(i.e, the inverse cases of what the previous sentence says). However, the current appearance of the structure of "if..." seems to have a reverse meaning. Specifically, the rule probably can be read as that
See this example
According to the diagnosis of GCC, the candidate set comprises
template<class T> Test(T, T)-> Test<T>
. The obscure structure can result in this issue.Issue 2:
Notice the bullet [1.6] and [1.7] in the above rule. It appears to me these bullets should be statements(general rules for aggregate CTAD), why are they placed after the
if
condition?The text was updated successfully, but these errors were encountered: