This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-11-11


1287. Direct initialization vs “implicit” conversion in reference binding

Section: 9.4.4  [dcl.init.ref]     Status: C++14     Submitter: Daniel Krügler     Date: 2011-04-06

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

In 9.4.5 [dcl.init.list] paragraph 5, both the cases in which a reference can be bound to the result of a conversion function use the phrase “can be implicitly converted to...” This is confusing, as it could be read as excluding explicit conversion functions. However, that appears not to be the intent, as 12.2.2.7 [over.match.ref], which is cited in these cases, allows explicit conversion functions for direct-initialization.

Proposed resolution (August, 2011) [SUPERSEDED]:

Change the two indicated (not contiguous) sub-bullets of 9.4.4 [dcl.init.ref] paragraph 5 as follows:

Additional note, January, 2012:

Questions have been raised regarding the consistency of the treatment of class prvalues in this resolution with other types . The issue is thus being returned to "review" status for additional discussion.

Proposed resolution (February, 2012) [SUPERSEDED]:

  1. Change 9.4.4 [dcl.init.ref] paragraph 5 as follows:

  2. A reference to type “cv1 T1” is initialized by an expression of type “cv2 T2” as follows:

  3. Change 12.2.2.7 [over.match.ref] paragraph 1 as follows:

  4. Under the conditions specified in 9.4.4 [dcl.init.ref], a reference can be bound directly to a glvalue or class prvalue that is the result of applying a conversion function...

Note from the April, 2013 meeting:

Because of concerns about slicing and performance in the February, 2012 proposed resolution, CWG decided to return to the August, 2011 proposed resolution and split off the discussion about class prvalues into issue 1650.

Proposed resolution (April, 2013):

Change the two indicated (not contiguous) sub-bullets of 9.4.4 [dcl.init.ref] paragraph 5 as follows: