Can a conditional operator generate a type of cv-qualified, array or function when using a cv-unqualified type of objects without an array on two x values?

Given two unqualified objects without an array, T1and T2can an expression true ? std::declval<T1>() : std::declval<T2>()be of type cv-qualified, array, or function? I am sure that he cannot, but I want to make sure that I did not miss anything.


Motivation: the current proposed resolution of LWG issue 2465 does not decay the type of conditional expression of the form true? std::declval<D1>() : std::declval<D2>()where D1it is D2created std::decay(and, therefore, are cv-unqualified objects without an array * ). This is true only if the expansion of the conditional expression type has no effect (which is not true if the type is a class with qualification, an array, or a function type ** ).

* Ignoring the case of "abnormal function types" that will never cause a valid expression, and the case void, which is a separate issue.
** Per [expr] / 5 , expressions never have a reference type.

+4
1

, [expr.cond]:

  1. , void, [...]

, void.

  1. , - glvalue cv1 T cv2 T, , cv T , cv - cv1 cv2.

, .

  1. , (, cv-) type, , cv-, (13.3.3.1) .

:

  • (4.1) E2 lvalue, , - "lvalue reference to T2" , [..].
  • (4.2) E2 - x, , - "rvalue reference to T2" , [..].

, , T2, cv-unqualified .

  • (4.3) E2 prvalue , (, cv-qualified) :
    • T1 T2 ( cv-), , T2 cv- T1, T2,
    • - - , E2 lvalue-to-rvalue (4.1), array-to-pointer (4.2) -to-pointer (4.3).

cv-unqualified .

, l-t-r cv-qualification ([conv.lval]/1). *-to-pointer ; , , ( -, ) , [expr]/6 . E2 T2, .

+4

Source: https://habr.com/ru/post/1651163/


All Articles