Title
Explicit conversion in copy/move list initialization
Status
cd4
Section
12.2.2.8 [over.match.list]
Submitter
Richard Smith

Created on 2013-09-21.00:00:00 last changed 87 months ago

Messages

Date: 2014-11-15.00:00:00

[Moved to DR at the November, 2014 meeting.]

Date: 2014-06-15.00:00:00

Proposed resolution (June, 2014):

This issue is resolved by the resolution of issue 1467.

Date: 2014-02-15.00:00:00

Notes from the February, 2014 meeting:

This issue should be addressed by the eventual resolution of issue 1467.

Date: 2013-09-21.00:00:00

Consider the following example:

  struct X { X(); };
  struct Y { explicit operator X(); } y;
  X x{y};

This appears to be ill-formed, although the corresponding case with parentheses is well-formed. There seem to be two factors that prevent this from being accepted:

First, the special provision allowing an explicit conversion function to be used when initializing the parameter of a copy/move constructor is in 12.2.2.5 [over.match.copy], and this case takes us to 12.2.2.8 [over.match.list] instead.

Second, 12.2.4.2 [over.best.ics] paragraph 4 says that in this case, because we are in 12.2.2.8 [over.match.list], and we have a single argument, and we are calling a copy/move constructor, we are not allowed to consider a user-defined conversion sequence for the argument.

Similarly, in an example like

  struct A {
   A() {}
   A(const A &) {}
  };
  struct B {
   operator A() { return A(); }
  } b;
  A a{b};

the wording in 12.2.4.2 [over.best.ics] paragraph 4 with regard to 12.2.2.8 [over.match.list] prevents considering B's conversion function when initializing the first parameter of A's copy constructor, thereby making this code ill-formed.

History
Date User Action Args
2017-02-06 00:00:00adminsetstatus: drwp -> cd4
2015-05-25 00:00:00adminsetstatus: dr -> drwp
2015-04-13 00:00:00adminsetmessages: + msg5403
2014-11-24 00:00:00adminsetstatus: ready -> dr
2014-07-07 00:00:00adminsetmessages: + msg5073
2014-07-07 00:00:00adminsetstatus: open -> ready
2014-03-03 00:00:00adminsetmessages: + msg4916
2013-09-21 00:00:00admincreate