|
2931 | 2931 | The \tcode{>} token following the
|
2932 | 2932 | \grammarterm{type-id} in a \tcode{dynamic_cast},
|
2933 | 2933 | \keyword{static_cast}, \tcode{reinterpret_cast}, or
|
2934 |
| -\tcode{const_cast} can be the product of replacing a |
| 2934 | +\keyword{const_cast} can be the product of replacing a |
2935 | 2935 | \tcode{>>} token by two consecutive \tcode{>}
|
2936 | 2936 | tokens\iref{temp.names}.
|
2937 | 2937 | \end{note}
|
|
3174 | 3174 | A function can change the values of its non-const parameters, but these
|
3175 | 3175 | changes cannot affect the values of the arguments except where a
|
3176 | 3176 | parameter is of a reference type\iref{dcl.ref}; if the reference is to
|
3177 |
| -a const-qualified type, \tcode{const_cast} is required to be used to |
| 3177 | +a const-qualified type, \keyword{const_cast} is required to be used to |
3178 | 3178 | cast away the constness in order to modify the argument's value. Where a
|
3179 | 3179 | parameter is of \tcode{const} reference type a temporary object is
|
3180 | 3180 | introduced if
|
|
4131 | 4131 | lvalue-to-rvalue\iref{conv.lval}, array-to-pointer\iref{conv.array},
|
4132 | 4132 | and function-to-pointer\iref{conv.func} standard conversions are
|
4133 | 4133 | performed on the expression \tcode{v}. Conversions that can be performed explicitly using
|
4134 |
| -\tcode{const_cast} are listed below. No other conversion shall be |
4135 |
| -performed explicitly using \tcode{const_cast}. |
| 4134 | +\keyword{const_cast} are listed below. No other conversion shall be |
| 4135 | +performed explicitly using \keyword{const_cast}. |
4136 | 4136 |
|
4137 | 4137 | \pnum
|
4138 | 4138 | \begin{note}
|
4139 | 4139 | Subject to the restrictions in this subclause, an expression can be cast
|
4140 |
| -to its own type using a \tcode{const_cast} operator. |
| 4140 | +to its own type using a \keyword{const_cast} operator. |
4141 | 4141 | \end{note}
|
4142 | 4142 |
|
4143 | 4143 | \pnum
|
4144 | 4144 | For two similar types \tcode{T1} and \tcode{T2}\iref{conv.qual},
|
4145 | 4145 | a prvalue of type \tcode{T1} may be explicitly
|
4146 |
| -converted to the type \tcode{T2} using a \tcode{const_cast} |
| 4146 | +converted to the type \tcode{T2} using a \keyword{const_cast} |
4147 | 4147 | if, considering the qualification-decompositions of both types,
|
4148 | 4148 | each $P^1_i$ is the same as $P^2_i$ for all $i$.
|
4149 |
| -The result of a \tcode{const_cast} refers to the original entity. |
| 4149 | +The result of a \keyword{const_cast} refers to the original entity. |
4150 | 4150 | \begin{example}
|
4151 | 4151 | \begin{codeblock}
|
4152 | 4152 | typedef int *A[3]; // array of 3 pointer to \tcode{int}
|
|
4162 | 4162 | \pnum
|
4163 | 4163 | For two object types \tcode{T1} and \tcode{T2}, if a pointer to \tcode{T1} can
|
4164 | 4164 | be explicitly converted to the type ``pointer to \tcode{T2}'' using a
|
4165 |
| -\tcode{const_cast}, then the following conversions can also be made: |
| 4165 | +\keyword{const_cast}, then the following conversions can also be made: |
4166 | 4166 | \begin{itemize}
|
4167 | 4167 | \item an lvalue of type \tcode{T1} can be explicitly converted to an lvalue
|
4168 | 4168 | of type \tcode{T2} using the cast \tcode{const_cast<T2\&>};
|
|
4175 | 4175 | \tcode{const_cast<T2\&\&>}.
|
4176 | 4176 | \end{itemize}
|
4177 | 4177 |
|
4178 |
| -The result of a reference \tcode{const_cast} refers |
| 4178 | +The result of a reference \keyword{const_cast} refers |
4179 | 4179 | to the original object if the operand is a glvalue and
|
4180 | 4180 | to the result of applying the temporary materialization conversion\iref{conv.rval} otherwise.
|
4181 | 4181 |
|
|
4189 | 4189 | \begin{note}
|
4190 | 4190 | Depending on the type of the object, a write operation through the
|
4191 | 4191 | pointer, lvalue or pointer to data member resulting from a
|
4192 |
| -\tcode{const_cast} that casts away a const-qualifier |
| 4192 | +\keyword{const_cast} that casts away a const-qualifier |
4193 | 4193 | \begin{footnote}
|
4194 |
| -\tcode{const_cast} |
| 4194 | +\keyword{const_cast} |
4195 | 4195 | is not limited to conversions that cast away a
|
4196 | 4196 | const-qualifier.
|
4197 | 4197 | \end{footnote}
|
|
5660 | 5660 | An explicit type conversion can be expressed using functional
|
5661 | 5661 | notation\iref{expr.type.conv}, a type conversion operator
|
5662 | 5662 | (\tcode{dynamic_cast}, \keyword{static_cast}, \tcode{reinterpret_cast},
|
5663 |
| -\tcode{const_cast}), or the \term{cast} notation. |
| 5663 | +\keyword{const_cast}), or the \term{cast} notation. |
5664 | 5664 |
|
5665 | 5665 | \begin{bnf}
|
5666 | 5666 | \nontermdef{cast-expression}\br
|
|
5678 | 5678 | \indextext{cast!const}%
|
5679 | 5679 | \indextext{cast!static}%
|
5680 | 5680 | \indextext{cast!reinterpret}%
|
5681 |
| -\item a \tcode{const_cast}\iref{expr.const.cast}, |
| 5681 | +\item a \keyword{const_cast}\iref{expr.const.cast}, |
5682 | 5682 | \item a \keyword{static_cast}\iref{expr.static.cast},
|
5683 |
| -\item a \keyword{static_cast} followed by a \tcode{const_cast}, |
| 5683 | +\item a \keyword{static_cast} followed by a \keyword{const_cast}, |
5684 | 5684 | \item a \tcode{reinterpret_cast}\iref{expr.reinterpret.cast}, or
|
5685 |
| -\item a \tcode{reinterpret_cast} followed by a \tcode{const_cast}, |
| 5685 | +\item a \tcode{reinterpret_cast} followed by a \keyword{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
|
|
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 |
| -\keyword{static_cast} followed by a \tcode{const_cast}, the conversion is |
| 5711 | +\keyword{static_cast} followed by a \keyword{const_cast}, the conversion is |
5712 | 5712 | ill-formed.
|
5713 | 5713 | \begin{example}
|
5714 | 5714 | \begin{codeblock}
|
|
0 commit comments