Title
Clarify implicit conversion sequence from cv T to T
Status
open
Section
12.2.4.2.1 [over.best.ics.general]
Submitter
Brian Bi

Created on 2024-05-30.00:00:00 last changed 5 months ago

Messages

Date: 2024-06-04.06:04:31

Suggested resolution:

  1. Change in 12.2.4.2.1 [over.best.ics.general] paragraph 6, moving the amended example to paragraph 7:

    ... Any difference in top-level cv-qualification is subsumed by the initialization itself and does not constitute a conversion. [Example 2: A parameter of type A can be initialized from an argument of type const A. The implicit conversion sequence for that case is the identity sequence; it contains no "conversion" from const A to A. -- end example]
  2. Change in 12.2.4.2.1 [over.best.ics.general] paragraph 7 as follows:

    When the parameter has a class type and the argument expression has the same type the cv-unqualified version of the type of the argument expression is the same as the parameter type, the implicit conversion sequence is an identity conversion. When the parameter has a class type and the argument expression has a (possibly cv-qualified) derived class type, the implicit conversion sequence is a derived-to-base conversion from the derived class to the base class. A derived-to-base conversion has Conversion rank (12.2.4.2.2 [over.ics.scs]). [Example: An implicit conversion sequence from an argument of type const A to a parameter of type A can be formed, even if overload resolution for copy-initialization of A from the argument would not find a viable function (12.2.2.4 [over.match.ctor], 12.2.3 [over.match.viable]). The implicit conversion sequence for that case is the identity sequence; it contains no "conversion" from const A to A. -- end example]
Date: 2024-05-30.00:00:00

(From submission #544.)

Subclause 12.2.4.2.1 [over.best.ics.general] paragraph 7 specifies:

When the parameter has a class type and the argument expression has the same type, the implicit conversion sequence is an identity conversion. When the parameter has a class type and the argument expression has a derived class type, the implicit conversion sequence is a derived-to-base conversion from the derived class to the base class. A derived-to-base conversion has Conversion rank (12.2.4.2.2 [over.ics.scs]).

Does "the same type" imply that differences in cv-qualification are significant? 12.2.4.2.1 [over.best.ics.general] paragraph 6 appears to differ:

... Any difference in top-level cv-qualification is subsumed by the initialization itself and does not constitute a conversion. [Example 2: A parameter of type A can be initialized from an argument of type const A. The implicit conversion sequence for that case is the identity sequence; it contains no "conversion" from const A to A. -- end example]

The example appears to reflect the intent; the normative wording should be clarified.

History
Date User Action Args
2024-06-02 09:52:22adminsetmessages: + msg7726
2024-05-30 00:00:00admincreate