Expression a = {1}; corresponds to case (10) of initialization of the copy list (see here ). Therefore, it must be correct in accordance with the standard.
The problem you are facing may have something to do with the following change from C ++ 11 to C ++ 14: in C ++ 11, when performing aggregate initialization, brackets around nested initializer lists can only be canceled if syntax ... = {...} but not ...{...} . In C ++ 14, the latter is also allowed. See here for more details. Now suppose C ++ 11 whether a = {1}; to be right or not? I think the answer depends on how you interpret the standard. Clearly, {1} used to initialize the second operand operator= . Below are two possible explanations, which respectively give a positive answer and a negative.
Explanation for a positive answer: the syntax ... = {...} executes copy-list-init, and ...{...} executes direct-list-init. So, what the standard says is that brace alignment is allowed in copy-list-init, but not in direct-list-init. a = {1}; executes copy-list-init. So, the elite is in order.
Explanation for a negative answer: just give a standard literal interpretation. Elision is in order with the appearance of an equal sign, and not otherwise. In a = {1}; initialization of the operand operator= is implicit without an equal sign. So this is not normal. The statement here seems to offer this verbatim explanation.
Lingxi
source share