Fix examples a7, a8 in [over.match.class.deduct]p6 #7444
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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) are non matching better each other (see https://godbolt.org/z/oejf5P1Tc).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&
.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).Linked Issue: #7445