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
A a7 = {0, i}; // error: #3 deduces to A<int&>, #1 and #2 declare same constructor
A a8{0,i}; // error: #3 deduces to A<int&>, #1 and #2 declare same constructor
Indeed, deduction fails because guides from #2 and #3 (see the full example in standard text or on godbolt link https://godbolt.org/z/oejf5P1Tc) are non matching better each other.
The aforementioned text reads, instead, that #3 wins (successful deduction) and then the error is because, consequently, constructors #1 and #2 ambiguate, which would be true in case the deduction had led to T = int&.
Suggested resolution:
I would propose the following changes, one with the error about overload resolution between two deduction guides, and one where a deduction guide wins and two equivalent constructors are consequently generated, so that both topics of the original comments are shown. I guess it is not that important to select between copy-list-initialization (a7) or not (a8), as another example (see a5 in standard text) already shows that the explicit user-defined deduction guide is involved (as per the text of [over.match.list]).
A a7 = {0, i}; // error: #2 and #3 both match, overload resolution fails
A a8{i,i}; // error: #3 deduces to A<int&>, #1 and #2 declare same constructor
Reporter: Mauro Russo
Reference (section label): [over.match.class.deduct] part 6
Link to reflector thread (if any):
None
Issue description:
The two examples (with
a7
anda8
) from [over.match.class.deduct]-p6 (draft of Nov 2024):...
...
are wrong, as preliminary discussed on:
https://lists.isocpp.org/std-discussion/2024/11/2715.php (and 2718.php)
https://lists.isocpp.org/std-discussion/2024/11/2736.php
Indeed, deduction fails because guides from
#2
and#3
(see the full example in standard text or on godbolt link https://godbolt.org/z/oejf5P1Tc) are non matching better each other.The aforementioned text reads, instead, that
#3
wins (successful deduction) and then the error is because, consequently, constructors#1
and#2
ambiguate, which would be true in case the deduction had led toT = int&
.Suggested resolution:
I would propose the following changes, one with the error about overload resolution between two deduction guides, and one where a deduction guide wins and two equivalent constructors are consequently generated, so that both topics of the original comments are shown. I guess it is not that important to select between copy-list-initialization (
a7
) or not (a8
), as another example (seea5
in standard text) already shows that theexplicit
user-defined deduction guide is involved (as per the text of [over.match.list]).(see https://godbolt.org/z/9Ecf8943x)
Do you believe it is interesting to highlight that even
#1
matches fora7
? (but#3
wins compared to it).Additional info:
Previously open as an issue here: cplusplus/draft#7445
There, see also cplusplus/draft#7444 if it helps.
The text was updated successfully, but these errors were encountered: