Movatterモバイル変換


[0]ホーム

URL:


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


5. CV-qualifiers and type conversions

Section:9.5  [dcl.init]    Status:CD1    Submitter:Josee Lajoie    Date:unknown

[Moved to DR at 4/01 meeting.]

The description of copy-initialization in 9.5 [dcl.init] paragraph 14says:

Should "destination type" in this last bullet refer to "cv-unqualifieddestination type" to make it clear that the destination type excludes anycv-qualifiers? This would make it clearer that the following example iswell-formed:
     struct A {       A(A&);     };     struct B : A { };     struct C {       operator B&();     };     C c;     const A a = c; // allowed?

The temporary created with the conversion function is an lvalue of typeB. If the temporary must have the cv-qualifiers of the destinationtype (i.e. const) then the copy-constructor forA cannot be calledto create the object of typeA from the lvalue of typeconstB. If the temporary has the cv-qualifiers of the result type of theconversion function, then the copy-constructor forA can be calledto create the object of typeA from the lvalue of typeconstB. This last outcome seems more appropriate.

Steve Adamczyk:

Because of late changes to this area, therelevant text is now the third sub-bullet of the fourth bullet of9.5 [dcl.init] paragraph 14:

Otherwise (i.e., for the remaining copy-initialization cases),user-defined conversion sequences that can convert from the sourcetype to the destination type or (when a conversion function is used)to a derived class thereof are enumerated...The function selected is called with the initializer expression as itsargument; if the function is a constructor, the call initializes atemporary of the destination type. The result of the call (which isthe temporary for the constructor case) is then used todirect-initialize, according to the rules above, the object that isthe destination of the copy-initialization.

The issue still remains whether the wording should refer to "thecv-unqualified version of the destination type." I think itshould.

Notes from 10/00 meeting:

The original example does not illustrate the remainingproblem. The following example does:

    struct C { };    C c;    struct A {        A(const A&);        A(const C&);    };    const volatile A a = c;    // Okay

Proposed Resolution (04/01):

In 9.5 [dcl.init], paragraph 14, bullet 4,sub-bullet 3, change

if the function is a constructor, the call initializes a temporaryof the destination type.

to

if the function is a constructor, the call initializes a temporaryof the cv-unqualified version of the destination type.



[8]ページ先頭

©2009-2025 Movatter.jp