Skip to content

Commit 76cba36

Browse files
committed
CWG2987 Remove dilapidated wording from static_cast
1 parent 393c299 commit 76cba36

File tree

1 file changed

+4
-33
lines changed

1 file changed

+4
-33
lines changed

source/expressions.tex

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4384,8 +4384,7 @@
43844384
If \tcode{T} is an lvalue reference type
43854385
or an rvalue reference to function type, the result is an lvalue;
43864386
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.
43894388

43904389
\pnum
43914390
\indextext{cast!static!reference}%
@@ -4474,36 +4473,11 @@
44744473
\end{note}
44754474

44764475
\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},
45014477
array-to-pointer\iref{conv.array}, and
45024478
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}.
45074481

45084482
\pnum
45094483
A value of a scoped enumeration type\iref{dcl.enum}
@@ -4619,9 +4593,6 @@
46194593
\end{codeblock}
46204594
\end{example}
46214595

4622-
\pnum
4623-
No other conversion can be performed using \keyword{static_cast}.
4624-
46254596
\rSec3[expr.reinterpret.cast]{Reinterpret cast}
46264597

46274598
\pnum

0 commit comments

Comments
 (0)