Skip to content

Commit 0b1cf18

Browse files
burblebeetkoeppe
authored andcommitted
CWG2894 Functional casts create prvalues of reference type
1 parent f304952 commit 0b1cf18

File tree

1 file changed

+38
-18
lines changed

1 file changed

+38
-18
lines changed

source/expressions.tex

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3559,6 +3559,44 @@
35593559
Otherwise, if the type contains a placeholder type,
35603560
it is replaced by the type
35613561
determined by placeholder type deduction\iref{dcl.type.auto.deduct}.
3562+
Let \tcode{T} denote the resulting type.
3563+
Then:
3564+
3565+
\begin{itemize}
3566+
\item
3567+
If the initializer is a parenthesized single expression,
3568+
the type conversion expression is equivalent
3569+
to the corresponding cast
3570+
expression\iref{expr.cast}.
3571+
3572+
\item
3573+
\indextext{type!incomplete}%
3574+
Otherwise, if \tcode{T} is \cv{}~\keyword{void},
3575+
the initializer shall be \tcode{()} or \tcode{\{\}}
3576+
(after pack expansion, if any), and
3577+
the expression is a prvalue of type \keyword{void}
3578+
that performs no initialization.
3579+
3580+
\item
3581+
Otherwise, if \tcode{T} is a reference type,
3582+
the expression has the same effect as
3583+
direct-initializing an invented variable \tcode{t} of type \tcode{T} from
3584+
the initializer and then
3585+
using \tcode{t} as the result of the expression;
3586+
the result is an lvalue if
3587+
\tcode{T} is an lvalue reference type or
3588+
an rvalue reference to function type and
3589+
an xvalue otherwise.
3590+
3591+
\item
3592+
Otherwise,
3593+
the expression is a prvalue of type \tcode{T}
3594+
whose result object is direct-initialized\iref{dcl.init}
3595+
with the initializer.
3596+
\end{itemize}
3597+
3598+
If the initializer is a parenthesized optional \grammarterm{expression-list},
3599+
\tcode{T} shall not be an array type.
35623600
\begin{example}
35633601
\begin{codeblock}
35643602
struct A {};
@@ -3573,24 +3611,6 @@
35733611
\end{codeblock}
35743612
\end{example}
35753613

3576-
\pnum
3577-
If the initializer is a parenthesized single expression,
3578-
the type conversion expression is equivalent
3579-
to the corresponding cast
3580-
expression\iref{expr.cast}.
3581-
\indextext{type!incomplete}%
3582-
Otherwise, if the type is \cv{}~\keyword{void}
3583-
and the initializer is \tcode{()} or \tcode{\{\}}
3584-
(after pack expansion, if any),
3585-
the expression is a prvalue of type \keyword{void}
3586-
that performs no initialization.
3587-
Otherwise,
3588-
the expression is a prvalue of the specified type
3589-
whose result object is direct-initialized\iref{dcl.init}
3590-
with the initializer.
3591-
If the initializer is a parenthesized optional \grammarterm{expression-list},
3592-
the specified type shall not be an array type.
3593-
35943614
\rSec3[expr.ref]{Class member access}
35953615

35963616
\pnum

0 commit comments

Comments
 (0)