|
4384 | 4384 | If \tcode{T} is an lvalue reference type
|
4385 | 4385 | or an rvalue reference to function type, the result is an lvalue;
|
4386 | 4386 | if \tcode{T} is an rvalue reference to object type, the result is an xvalue;
|
4387 |
| -otherwise, the result is a prvalue. The \keyword{static_cast} operator shall not cast |
4388 |
| -away constness\iref{expr.const.cast}. |
| 4387 | +otherwise, the result is a prvalue. |
4389 | 4388 |
|
4390 | 4389 | \pnum
|
4391 | 4390 | \indextext{cast!static!reference}%
|
|
4474 | 4473 | \end{note}
|
4475 | 4474 |
|
4476 | 4475 | \pnum
|
4477 |
| -Otherwise, |
4478 |
| -the inverse of a standard conversion sequence\iref{conv} not containing an |
4479 |
| -lvalue-to-rvalue\iref{conv.lval}, |
4480 |
| -array-to-pointer\iref{conv.array}, |
4481 |
| -function-to-pointer\iref{conv.func}, |
4482 |
| -null pointer\iref{conv.ptr}, null member pointer\iref{conv.mem}, |
4483 |
| -boolean\iref{conv.bool}, or |
4484 |
| -function pointer\iref{conv.fctptr} |
4485 |
| -conversion, can be performed explicitly using \keyword{static_cast}. A |
4486 |
| -program is ill-formed if it uses \keyword{static_cast} to perform the |
4487 |
| -inverse of an ill-formed standard conversion sequence. |
4488 |
| -\begin{example} |
4489 |
| -\begin{codeblock} |
4490 |
| -struct B { }; |
4491 |
| -struct D : private B { }; |
4492 |
| -void f() { |
4493 |
| - static_cast<D*>((B*)0); // error: \tcode{B} is a private base of \tcode{D} |
4494 |
| - static_cast<int B::*>((int D::*)0); // error: \tcode{B} is a private base of \tcode{D} |
4495 |
| -} |
4496 |
| -\end{codeblock} |
4497 |
| -\end{example} |
4498 |
| - |
4499 |
| -\pnum |
4500 |
| -The lvalue-to-rvalue\iref{conv.lval}, |
| 4476 | +Otherwise, the lvalue-to-rvalue\iref{conv.lval}, |
4501 | 4477 | array-to-pointer\iref{conv.array}, and
|
4502 | 4478 | function-to-pointer\iref{conv.func} conversions are applied to the
|
4503 |
| -operand. Such a \keyword{static_cast} is subject to the restriction that |
4504 |
| -the explicit conversion does not cast away |
4505 |
| -constness\iref{expr.const.cast}, and the following additional rules |
4506 |
| -for specific cases: |
| 4479 | +operand, and the conversions that can be performed using \keyword{static_cast} are listed below. |
| 4480 | +No other conversion can be performed using \keyword{static_cast}. |
4507 | 4481 |
|
4508 | 4482 | \pnum
|
4509 | 4483 | A value of a scoped enumeration type\iref{dcl.enum}
|
|
4619 | 4593 | \end{codeblock}
|
4620 | 4594 | \end{example}
|
4621 | 4595 |
|
4622 |
| -\pnum |
4623 |
| -No other conversion can be performed using \keyword{static_cast}. |
4624 |
| - |
4625 | 4596 | \rSec3[expr.reinterpret.cast]{Reinterpret cast}
|
4626 | 4597 |
|
4627 | 4598 | \pnum
|
|
0 commit comments