C++ Logo

std-discussion

Advanced search

Re: What does this sentence in the definition of COMMON-REF mean?

From: Edward Catmur <ecatmur_at_[hidden]>
Date: Fri, 18 Nov 2022 10:17:55 +0000
On Fri, 18 Nov 2022 at 04:46, Eric Schmidt via Std-Discussion <
std-discussion_at_[hidden]> wrote:

> https://eel.is/c++draft/meta.trans.other
>
> The definition of COMMON-REF concludes with, "If any of the types
> computed above is ill-formed, then COMMON-REF(A, B) is ill-formed."
>
> I'm not sure what this means. My first inclination is that it means, if
> the type formed for the particular case is ill-formed, then
> COMMON-REF(A, B) is ill-formed. But this seems redundant with the
> immediately preceding statement, "Otherwise, COMMON-REF(A, B) is
> ill-formed."
>
> The other interpretation is that if the type of any of the four cases is
> ill-formed, then COMMON-REF(A, B) is ill-formed even if a different case
> applies. But it seems odd to me to say that, if X is A& and Y is B&,
> that COMMON-REF(X, Y) is ill-formed if the type for the mixed rvalue and
> lvalue reference case, namely, COMMON-REF(const A&, B&), is ill-formed.
>
> Can anyone shed some light on this?
>

I think it makes slightly more sense in the original:

> Given types A and B, let X be remove_reference_t<A>, let Y be
> remove_reference_t<B>, and let COMMON_REF(A,B) be:
>
> (3.1) – If A and B are both lvalue reference types, COMMON_REF(A,B) is COND_RES(COPYCV(X,Y)
> &, COPYCV(Y,X) &).
> (3.2) – If A and B are both rvalue reference types, and COMMON_RES(X&,Y&) is
> well formed, and is_convertible<A,R>::value and is_convertible<B,R>::value are
> true where R is remove_reference_t<COMMON_RES(X&,Y&)>&& if
> COMMON_RES(X&,Y&) is a reference type or COMMON_RES(X&,Y&) otherwise,
> then COMMON_RES(A,B) is R.
> (3.3) – If A is an rvalue reference and B is an lvalue reference and COMMON_REF(const
> X&, Y&) is well formed and is_convertible<A,R>::value is true where R is COMMON_REF(const
> X&, Y&) then COMMON_RES(A,B) is R.
> (3.4) – If A is an lvalue reference and B is an rvalue reference, then
> COMMON_REF(A,B) is COMMON_REF(B,A).
> (3.5) – Otherwise, COMMON_REF(A,B) is decay_t<COND_RES(CREF(A),CREF(B))>.
>
> If any of the types computed above are ill-formed, then COMMON_REF(A,B) is
> ill-formed.
>
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0022r0.html#chapter-20-general-utilities

Not a huge amount more sense, admittedly, but at least the redundancy isn't
there.

Received on 2022-11-18 10:18:07