You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If T1 or T2 is a class type and T1 is not reference-related to T2, user-defined conversions are
considered using the rules for copy-initialization of an object of type “cv1 T1” by user-defined
conversion (9.4, 12.4.1.4, 12.4.1.5); the program is ill-formed if the corresponding non-reference
copy-initialization would be ill-formed. The result of the call to the conversion function, as
described for the non-reference copy-initialization, is then used to direct-initialize the reference.
For this direct-initialization, user-defined conversions are not considered.
The highlighted wording (which requires performing direct initialization after applying the user-defined conversion) was added in CWG1604. Given that "user-defined conversions are not considered" for the next step of the initialization, I believe that requiring a specific type of initialization does not have any effect on the outcome.
I think there is another issue with the quoted text above, namely:
[...] The result of the call to the conversion function [...]
I believe that the user-defined conversion referred to here could use either a converting constructor or a conversion function, not just a conversion function.
Thank you!
The text was updated successfully, but these errors were encountered:
Also, the last sentence from the quoted text: [...] For this direct-initialization, user-defined conversions are not considered.
seems to be superfluous, as the type that results from [over.match.copy] or [over.match.conv] (henceforth referred to as T3) is:
T1 or a type derived from T1 (in case T1 is a class type; [over.match.copy]), or
T1 or a type that can be converted to T1 using a standard conversion sequence (in case T1 is not a class type; [over.match.conv])
Only the first case (T1 is a class type) is of interest (otherwise user-defined conversions are excluded by default in the second stage of the initialization). T3 is reference-related to T1, and [dcl.init.ref] paragraph 5 only considers user-defined conversions in case the reference type and the initializer type are not reference-related. Therefore explicitly disallowing user-defined conversions in the second stage of the reference initialization is not required.
I believe the restriction was unnecessary even considering the state of the standard when the resolution for CWG1604 was proposed (the resolution for CWG1604 added this restriction).
[dcl.init.ref] paragraph 5, bullet 4, sub-bullet 1 specifies the following:
The highlighted wording (which requires performing direct initialization after applying the user-defined conversion) was added in CWG1604. Given that "user-defined conversions are not considered" for the next step of the initialization, I believe that requiring a specific type of initialization does not have any effect on the outcome.
I think there is another issue with the quoted text above, namely:
I believe that the user-defined conversion referred to here could use either a converting constructor or a conversion function, not just a conversion function.
Thank you!
The text was updated successfully, but these errors were encountered: