CWG Issue 1527 (original) (raw)
This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 118e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-11-05
1527. Assignment from braced-init-list
Section: 7.6.19 [expr.assign]Status: CD3Submitter: Mike MillerDate: 2012-07-23
[Moved to DR at the April, 2013 meeting.]
According to 7.6.19 [expr.assign] paragraph 9,
A braced-init-list may appear on the right-hand side of
- an assignment to a scalar...
- an assignment defined by a user-defined assignment operator, in which case the initializer list is passed as the argument to the operator function.
Presumably the phrase “user-defined” is not intended to forbid an example like
struct A { A(); A ( std::initializer_list ) ; }; void f() { A a; a = {37}; }
which relies on an implicitly-declared assignment operator.
Proposed resolution (August, 2012):
Change 7.6.19 [expr.assign] paragraph 9 as follows:
A braced-init-list may appear on the right-hand side of
- an assignment to a scalar, in which case the initializer list shall have at most a single element. The meaning ofx={v}, where T is the scalar type of the expressionx, is that of x=T(v) except that no narrowing conversion (8.5.4) is allowed. The meaning of x={} isx=T().
- an assignment
defined by a user-defined assignment operatorto an object of class type, in which case the initializer list is passed as the argument to theassignment operator function selected by overload resolution (12.4.3.2 [over.assign], 12.2 [over.match]).