C++ Logo

std-discussion

Advanced search

Re: wrong examples in standard text (also based on major compilers)

From: Brian Bi <bbi5291_at_[hidden]>
Date: Mon, 25 Nov 2024 17:11:56 -0500
On Mon, Nov 25, 2024 at 5:09 PM mauro russo <ing.russomauro_at_[hidden]>
wrote:

>
> > I agree, these examples seem to be wrong, Binding `int&&`
> > to an rvalue is better than binding `const int&` to an rvalue,
> > but then for the other argument we have that binding
> > `const int&` to an rvalue is better than the ellipsis.
>
> Should I open an issue with PR for that ?
>

I think this issue has to be reviewed by CWG. If you can propose a better
(and correct) example then please do. But you can also submit the issue
without it.


>
>
> > If `T` is `int&`, then `const T&` and `T&&` are both `int&`.
>
> Sure, I agree... in the sense that this would be
> true if deduction would lead to int&.
> However, since we agree above that deduction
> fails, the statement about #1 and #2 is
> consequently wrong, isn't it ?
>
>>
I think it would be ideal to amend the example so that we still deduce to
`A<int&>`, but obviously if we end up not doing that, then we may not end
up with an error upon instantiation.

-- 
*Brian Bi*

Received on 2024-11-25 22:12:11