|
486 | 486 | The \tcode{mutable} specifier on a class data member nullifies a
|
487 | 487 | \tcode{const} specifier applied to the containing class object and
|
488 | 488 | permits modification of the mutable class member even though the rest of
|
489 |
| -the object is \tcode{const}~(\ref{dcl.type.cv}). |
| 489 | +the object is const~(\ref{dcl.type.cv}). |
490 | 490 |
|
491 | 491 | \rSec2[dcl.fct.spec]{Function specifiers}%
|
492 | 492 | \indextext{specifier!function}%
|
|
943 | 943 |
|
944 | 944 | \pnum
|
945 | 945 | A \tcode{constexpr} specifier used in an object declaration
|
946 |
| -declares the object as \tcode{const}. |
| 946 | +declares the object as const. |
947 | 947 | Such an object
|
948 | 948 | shall have literal type and
|
949 | 949 | shall be initialized.
|
|
1154 | 1154 | \end{note}
|
1155 | 1155 |
|
1156 | 1156 | \pnum
|
1157 |
| -\indextext{const object@\tcode{const}-object!undefined change to}% |
| 1157 | +\indextext{const object!undefined change to}% |
1158 | 1158 | Except that any class member declared \tcode{mutable}~(\ref{dcl.stc})
|
1159 |
| -can be modified, any attempt to modify a \tcode{const} object during its |
| 1159 | +can be modified, any attempt to modify a const object during its |
1160 | 1160 | lifetime~(\ref{basic.life}) results in undefined behavior.
|
1161 | 1161 | \begin{example}
|
1162 | 1162 | \begin{codeblock}
|
|
1170 | 1170 |
|
1171 | 1171 | int* ip;
|
1172 | 1172 | ip = const_cast<int*>(cip); // cast needed to convert \tcode{const int*} to \tcode{int*}
|
1173 |
| -*ip = 4; // defined: \tcode{*ip} points to \tcode{i}, a non-\tcode{const} object |
| 1173 | +*ip = 4; // defined: \tcode{*ip} points to \tcode{i}, a non-const object |
1174 | 1174 |
|
1175 | 1175 | const int* ciq = new const int (3); // initialized as required
|
1176 | 1176 | int* iq = const_cast<int*>(ciq); // cast required
|
1177 |
| -*iq = 4; // undefined: modifies a \tcode{const} object |
| 1177 | +*iq = 4; // undefined: modifies a const object |
1178 | 1178 | \end{codeblock}
|
1179 | 1179 | For another example,
|
1180 | 1180 | \begin{codeblock}
|
|
1192 | 1192 | y.x.j++; // ill-formed: const-qualified member modified
|
1193 | 1193 | Y* p = const_cast<Y*>(&y); // cast away const-ness of \tcode{y}
|
1194 | 1194 | p->x.i = 99; // well-formed: \tcode{mutable} member can be modified
|
1195 |
| -p->x.j = 99; // undefined: modifies a \tcode{const} member |
| 1195 | +p->x.j = 99; // undefined: modifies a const subobject |
1196 | 1196 | \end{codeblock}
|
1197 | 1197 | \end{example}
|
1198 | 1198 |
|
|
0 commit comments