|
2930 | 2930 | \begin{note}
|
2931 | 2931 | The \tcode{>} token following the
|
2932 | 2932 | \grammarterm{type-id} in a \tcode{dynamic_cast},
|
2933 |
| -\tcode{static_cast}, \tcode{reinterpret_cast}, or |
| 2933 | +\keyword{static_cast}, \tcode{reinterpret_cast}, or |
2934 | 2934 | \tcode{const_cast} can be the product of replacing a
|
2935 | 2935 | \tcode{>>} token by two consecutive \tcode{>}
|
2936 | 2936 | tokens\iref{temp.names}.
|
|
3718 | 3718 | If \tcode{T} is an lvalue reference type
|
3719 | 3719 | or an rvalue reference to function type, the result is an lvalue;
|
3720 | 3720 | if \tcode{T} is an rvalue reference to object type, the result is an xvalue;
|
3721 |
| -otherwise, the result is a prvalue. The \tcode{static_cast} operator shall not cast |
| 3721 | +otherwise, the result is a prvalue. The \keyword{static_cast} operator shall not cast |
3722 | 3722 | away constness\iref{expr.const.cast}.
|
3723 | 3723 |
|
3724 | 3724 | \pnum
|
|
3759 | 3759 | the result refers to the object or the specified base class subobject
|
3760 | 3760 | thereof; otherwise, the lvalue-to-rvalue conversion\iref{conv.lval}
|
3761 | 3761 | is applied to the bit-field and the resulting prvalue is used as the
|
3762 |
| -\grammarterm{expression} of the \tcode{static_cast} for the remainder of this subclause. |
| 3762 | +\grammarterm{expression} of the \keyword{static_cast} for the remainder of this subclause. |
3763 | 3763 | If \tcode{T2} is an inaccessible\iref{class.access} or
|
3764 | 3764 | ambiguous\iref{class.member.lookup} base class of \tcode{T1},
|
3765 | 3765 | a program that necessitates such a cast is ill-formed.
|
|
3793 | 3793 | \end{note}
|
3794 | 3794 |
|
3795 | 3795 | \pnum
|
3796 |
| -Otherwise, the \tcode{static_cast} shall perform one of the conversions |
| 3796 | +Otherwise, the \keyword{static_cast} shall perform one of the conversions |
3797 | 3797 | listed below. No other conversion shall be performed explicitly using a
|
3798 |
| -\tcode{static_cast}. |
| 3798 | +\keyword{static_cast}. |
3799 | 3799 |
|
3800 | 3800 | \pnum
|
3801 | 3801 | Any expression can be explicitly converted to type \cv{}~\tcode{void},
|
|
3818 | 3818 | null pointer\iref{conv.ptr}, null member pointer\iref{conv.mem},
|
3819 | 3819 | boolean\iref{conv.bool}, or
|
3820 | 3820 | function pointer\iref{conv.fctptr}
|
3821 |
| -conversion, can be performed explicitly using \tcode{static_cast}. A |
3822 |
| -program is ill-formed if it uses \tcode{static_cast} to perform the |
| 3821 | +conversion, can be performed explicitly using \keyword{static_cast}. A |
| 3822 | +program is ill-formed if it uses \keyword{static_cast} to perform the |
3823 | 3823 | inverse of an ill-formed standard conversion sequence.
|
3824 | 3824 | \begin{example}
|
3825 | 3825 | \begin{codeblock}
|
|
3836 | 3836 | The lvalue-to-rvalue\iref{conv.lval},
|
3837 | 3837 | array-to-pointer\iref{conv.array}, and
|
3838 | 3838 | function-to-pointer\iref{conv.func} conversions are applied to the
|
3839 |
| -operand. Such a \tcode{static_cast} is subject to the restriction that |
| 3839 | +operand. Such a \keyword{static_cast} is subject to the restriction that |
3840 | 3840 | the explicit conversion does not cast away
|
3841 | 3841 | constness\iref{expr.const.cast}, and the following additional rules
|
3842 | 3842 | for specific cases:
|
|
5659 | 5659 | \pnum
|
5660 | 5660 | An explicit type conversion can be expressed using functional
|
5661 | 5661 | notation\iref{expr.type.conv}, a type conversion operator
|
5662 |
| -(\tcode{dynamic_cast}, \tcode{static_cast}, \tcode{reinterpret_cast}, |
| 5662 | +(\tcode{dynamic_cast}, \keyword{static_cast}, \tcode{reinterpret_cast}, |
5663 | 5663 | \tcode{const_cast}), or the \term{cast} notation.
|
5664 | 5664 |
|
5665 | 5665 | \begin{bnf}
|
|
5679 | 5679 | \indextext{cast!static}%
|
5680 | 5680 | \indextext{cast!reinterpret}%
|
5681 | 5681 | \item a \tcode{const_cast}\iref{expr.const.cast},
|
5682 |
| -\item a \tcode{static_cast}\iref{expr.static.cast}, |
5683 |
| -\item a \tcode{static_cast} followed by a \tcode{const_cast}, |
| 5682 | +\item a \keyword{static_cast}\iref{expr.static.cast}, |
| 5683 | +\item a \keyword{static_cast} followed by a \tcode{const_cast}, |
5684 | 5684 | \item a \tcode{reinterpret_cast}\iref{expr.reinterpret.cast}, or
|
5685 | 5685 | \item a \tcode{reinterpret_cast} followed by a \tcode{const_cast},
|
5686 | 5686 | \end{itemize}
|
5687 | 5687 | can be performed using the cast notation of explicit type conversion.
|
5688 | 5688 | The same semantic restrictions and behaviors apply, with the exception
|
5689 |
| -that in performing a \tcode{static_cast} in the following situations the |
| 5689 | +that in performing a \keyword{static_cast} in the following situations the |
5690 | 5690 | conversion is valid even if the base class is inaccessible:
|
5691 | 5691 | \begin{itemize}
|
5692 | 5692 | \item a pointer to an object of derived class type or an lvalue or
|
|
5708 | 5708 | above, the interpretation that appears first in the list is used, even
|
5709 | 5709 | if a cast resulting from that interpretation is ill-formed. If a
|
5710 | 5710 | conversion can be interpreted in more than one way as a
|
5711 |
| -\tcode{static_cast} followed by a \tcode{const_cast}, the conversion is |
| 5711 | +\keyword{static_cast} followed by a \tcode{const_cast}, the conversion is |
5712 | 5712 | ill-formed.
|
5713 | 5713 | \begin{example}
|
5714 | 5714 | \begin{codeblock}
|
|
5717 | 5717 | struct I2 : A { };
|
5718 | 5718 | struct D : I1, I2 { };
|
5719 | 5719 | A* foo( D* p ) {
|
5720 |
| - return (A*)( p ); // ill-formed \tcode{static_cast} interpretation |
| 5720 | + return (A*)( p ); // ill-formed \keyword{static_cast} interpretation |
5721 | 5721 | }
|
5722 | 5722 | \end{codeblock}
|
5723 | 5723 | \end{example}
|
|
5728 | 5728 | ``pointer to incomplete class type''. The destination type of a cast
|
5729 | 5729 | using the cast notation can be ``pointer to incomplete class type''. If
|
5730 | 5730 | both the operand and destination types are class types and one or both
|
5731 |
| -are incomplete, it is unspecified whether the \tcode{static_cast} or the |
| 5731 | +are incomplete, it is unspecified whether the \keyword{static_cast} or the |
5732 | 5732 | \tcode{reinterpret_cast} interpretation is used, even if there is an
|
5733 | 5733 | inheritance relationship between the two classes.
|
5734 | 5734 | \begin{note}
|
|
0 commit comments