Title
Assignment from braced-init-list
Status
cd3
Section
7.6.19 [expr.ass]
Submitter
Mike Miller

Created on 2012-07-23.00:00:00 last changed 131 months ago

Messages

Date: 2013-04-15.00:00:00

[Moved to DR at the April, 2013 meeting.]

Date: 2012-08-15.00:00:00

Proposed resolution (August, 2012):

Change 7.6.19 [expr.ass] 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 of x={v}, where T is the scalar type of the expression x, is that of x=T(v) except that no narrowing conversion (8.5.4) is allowed. The meaning of x={} is x=T().

  • an assignment defined by a user-defined assignment operator to an object of class type, in which case the initializer list is passed as the argument to the assignment operator function selected by overload resolution (12.4.3.2 [over.ass], 12.2 [over.match]).

Date: 2012-07-23.00:00:00

According to 7.6.19 [expr.ass] 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<int> ) ;
  };
  void f() {
    A a;
    a = {37};
  }

which relies on an implicitly-declared assignment operator.

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: drwp -> cd3
2013-10-14 00:00:00adminsetstatus: dr -> drwp
2013-05-03 00:00:00adminsetmessages: + msg4391
2013-05-03 00:00:00adminsetstatus: ready -> dr
2012-11-03 00:00:00adminsetstatus: tentatively ready -> ready
2012-09-24 00:00:00adminsetmessages: + msg3879
2012-07-23 00:00:00admincreate