|
4119 | 4119 | a program that necessitates such a cast is ill-formed.
|
4120 | 4120 |
|
4121 | 4121 | \pnum
|
4122 |
| -An expression $E$ can be explicitly converted to a type \tcode{T} |
| 4122 | +Any expression can be explicitly converted to type \cv{}~\keyword{void}, |
| 4123 | +in which case the operand is a discarded-value expression\iref{expr.prop}. |
| 4124 | +\begin{note} |
| 4125 | +Such a \keyword{static_cast} has no result |
| 4126 | +as it is a prvalue of type \keyword{void}; see~\ref{basic.lval}. |
| 4127 | +\end{note} |
| 4128 | +\begin{note} |
| 4129 | +However, if the value is in a temporary |
| 4130 | +object\iref{class.temporary}, the destructor for that |
| 4131 | +object is |
| 4132 | +not executed until the usual time, and the value of the object is |
| 4133 | +preserved for the purpose of executing the destructor. |
| 4134 | +\end{note} |
| 4135 | + |
| 4136 | +\pnum |
| 4137 | +Otherwise, an expression $E$ can be explicitly converted to a type \tcode{T} |
4123 | 4138 | if there is an implicit conversion sequence\iref{over.best.ics}
|
4124 | 4139 | from $E$ to \tcode{T},
|
4125 | 4140 | if overload resolution for a direct-initialization\iref{dcl.init}
|
|
4147 | 4162 | \end{note}
|
4148 | 4163 |
|
4149 | 4164 | \pnum
|
4150 |
| -Otherwise, the \keyword{static_cast} shall perform one of the conversions |
4151 |
| -listed below. No other conversion shall be performed explicitly using a |
4152 |
| -\keyword{static_cast}. |
4153 |
| - |
4154 |
| -\pnum |
4155 |
| -Any expression can be explicitly converted to type \cv{}~\keyword{void}, |
4156 |
| -in which case the operand is a discarded-value expression\iref{expr.prop}. |
4157 |
| -\begin{note} |
4158 |
| -Such a \keyword{static_cast} has no result |
4159 |
| -as it is a prvalue of type \keyword{void}; see~\ref{basic.lval}. |
4160 |
| -\end{note} |
4161 |
| -\begin{note} |
4162 |
| -However, if the value is in a temporary |
4163 |
| -object\iref{class.temporary}, the destructor for that |
4164 |
| -object is |
4165 |
| -not executed until the usual time, and the value of the object is |
4166 |
| -preserved for the purpose of executing the destructor. |
4167 |
| -\end{note} |
4168 |
| - |
4169 |
| - |
4170 |
| -\pnum |
4171 |
| -The inverse of any standard conversion sequence\iref{conv} not containing an |
| 4165 | +Otherwise, |
| 4166 | +the inverse of a standard conversion sequence\iref{conv} not containing an |
4172 | 4167 | lvalue-to-rvalue\iref{conv.lval},
|
4173 | 4168 | array-to-pointer\iref{conv.array},
|
4174 | 4169 | function-to-pointer\iref{conv.func},
|
|
4312 | 4307 | \end{codeblock}
|
4313 | 4308 | \end{example}
|
4314 | 4309 |
|
| 4310 | +\pnum |
| 4311 | +No other conversion can be performed using \keyword{static_cast}. |
| 4312 | + |
4315 | 4313 | \rSec3[expr.reinterpret.cast]{Reinterpret cast}
|
4316 | 4314 |
|
4317 | 4315 | \pnum
|
|
0 commit comments