|
548 | 548 |
|
549 | 549 | \pnum
|
550 | 550 | A data member or member function
|
551 |
| -may be declared \tcode{static} in its \grammarterm{member-declaration}, |
| 551 | +may be declared \keyword{static} in its \grammarterm{member-declaration}, |
552 | 552 | in which case it is a \defnadj{static}{member} (see~\ref{class.static})
|
553 | 553 | (a \defnadj{static}{data member}\iref{class.static.data} or
|
554 | 554 | \defnadj{static}{member function}\iref{class.static.mfct}, respectively)
|
|
658 | 658 | exception specification of that constructor.
|
659 | 659 |
|
660 | 660 | \pnum
|
661 |
| -A member shall not be declared with the \tcode{extern} |
662 |
| -\grammarterm{storage-class-specifier}. Within a class definition, a member shall not be declared with the \tcode{thread_local} \grammarterm{storage-class-specifier} unless also declared \tcode{static}. |
| 661 | +A member shall not be declared with the \keyword{extern} |
| 662 | +\grammarterm{storage-class-specifier}. Within a class definition, a member shall not be declared with the \tcode{thread_local} \grammarterm{storage-class-specifier} unless also declared \keyword{static}. |
663 | 663 |
|
664 | 664 | \pnum
|
665 | 665 | The \grammarterm{decl-specifier-seq} may be omitted in constructor, destructor,
|
|
866 | 866 | it is inline\iref{dcl.inline}.
|
867 | 867 | \begin{note}
|
868 | 868 | A member function is also inline if it is declared
|
869 |
| -\tcode{inline}, \keyword{constexpr}, or \keyword{consteval}. |
| 869 | +\keyword{inline}, \keyword{constexpr}, or \keyword{consteval}. |
870 | 870 | \end{note}
|
871 | 871 |
|
872 | 872 | \pnum
|
|
1141 | 1141 | \end{itemize}
|
1142 | 1142 | Constructors do not have names.
|
1143 | 1143 | In a constructor declaration, each \grammarterm{decl-specifier} in the optional
|
1144 |
| -\grammarterm{decl-specifier-seq} shall be \tcode{friend}, \tcode{inline}, |
| 1144 | +\grammarterm{decl-specifier-seq} shall be \keyword{friend}, \keyword{inline}, |
1145 | 1145 | \keyword{constexpr}, or an \grammarterm{explicit-specifier}.
|
1146 | 1146 | \begin{example}
|
1147 | 1147 | \begin{codeblock}
|
|
1194 | 1194 | \indextext{\idxcode{const}!constructor and}%
|
1195 | 1195 | \indextext{\idxcode{volatile}!constructor and}%
|
1196 | 1196 | A constructor can be invoked for a
|
1197 |
| -\tcode{const}, |
| 1197 | +\keyword{const}, |
1198 | 1198 | \tcode{volatile}
|
1199 | 1199 | or
|
1200 |
| -\tcode{const} |
| 1200 | +\keyword{const} |
1201 | 1201 | \tcode{volatile}
|
1202 | 1202 | object.
|
1203 | 1203 | \indextext{restriction!constructor}%
|
1204 |
| -\tcode{const} |
| 1204 | +\keyword{const} |
1205 | 1205 | and
|
1206 | 1206 | \tcode{volatile}
|
1207 | 1207 | semantics\iref{dcl.type.cv} are not applied on an object under construction.
|
|
1431 | 1431 | only has a copy constructor with a parameter of type
|
1432 | 1432 | \tcode{X\&},
|
1433 | 1433 | an initializer of type
|
1434 |
| -\tcode{const} |
| 1434 | +\keyword{const} |
1435 | 1435 | \tcode{X}
|
1436 | 1436 | or
|
1437 | 1437 | \tcode{volatile}
|
|
1496 | 1496 | \tcode{M}
|
1497 | 1497 | (or array thereof)
|
1498 | 1498 | has a copy constructor whose first parameter is of type
|
1499 |
| -\tcode{const} |
| 1499 | +\keyword{const} |
1500 | 1500 | \tcode{M\&}
|
1501 | 1501 | or
|
1502 |
| -\tcode{const} |
| 1502 | +\keyword{const} |
1503 | 1503 | \tcode{volatile}
|
1504 | 1504 | \tcode{M\&}.
|
1505 | 1505 | \begin{footnote}
|
|
1846 | 1846 | \item a variant member with a non-trivial corresponding assignment operator and
|
1847 | 1847 | \tcode{X} is a union-like class, or
|
1848 | 1848 |
|
1849 |
| -\item a non-static data member of \tcode{const} non-class |
| 1849 | +\item a non-static data member of \keyword{const} non-class |
1850 | 1850 | type (or array thereof), or
|
1851 | 1851 |
|
1852 | 1852 | \item a non-static data member of reference type, or
|
|
2036 | 2036 | Each \grammarterm{decl-specifier} of the \grammarterm{decl-specifier-seq}
|
2037 | 2037 | of a prospective destructor declaration (if any)
|
2038 | 2038 | shall be
|
2039 |
| -\tcode{friend}, |
2040 |
| -\tcode{inline}, |
2041 |
| -\tcode{virtual}, |
| 2039 | +\keyword{friend}, |
| 2040 | +\keyword{inline}, |
| 2041 | +\keyword{virtual}, |
2042 | 2042 | \keyword{constexpr}, or
|
2043 | 2043 | \keyword{consteval}.
|
2044 | 2044 |
|
|
2079 | 2079 | \indextext{\idxcode{const}!destructor and}%
|
2080 | 2080 | \indextext{\idxcode{volatile}!destructor and}%
|
2081 | 2081 | A destructor can be invoked for a
|
2082 |
| -\tcode{const}, |
| 2082 | +\keyword{const}, |
2083 | 2083 | \tcode{volatile}
|
2084 | 2084 | or
|
2085 |
| -\tcode{const} |
| 2085 | +\keyword{const} |
2086 | 2086 | \tcode{volatile}
|
2087 | 2087 | object.
|
2088 |
| -\tcode{const} |
| 2088 | +\keyword{const} |
2089 | 2089 | and
|
2090 | 2090 | \tcode{volatile}
|
2091 | 2091 | semantics\iref{dcl.type.cv} are not applied on an object under destruction.
|
|
2492 | 2492 | Such functions are called \defnx{conversion functions}{conversion function}.
|
2493 | 2493 | A \grammarterm{decl-specifier} in the \grammarterm{decl-specifier-seq}
|
2494 | 2494 | of a conversion function (if any) shall be neither
|
2495 |
| -a \grammarterm{defining-type-specifier} nor \tcode{static}. |
| 2495 | +a \grammarterm{defining-type-specifier} nor \keyword{static}. |
2496 | 2496 | \indextext{conversion!type of}%
|
2497 | 2497 | The type of the conversion function\iref{dcl.fct} is
|
2498 | 2498 | ``function taking no parameter returning
|
|
2653 | 2653 | \pnum
|
2654 | 2654 | Static members obey the usual class member access rules\iref{class.access}.
|
2655 | 2655 | When used in the declaration of a class
|
2656 |
| -member, the \tcode{static} specifier shall only be used in the member |
| 2656 | +member, the \keyword{static} specifier shall only be used in the member |
2657 | 2657 | declarations that appear within the \grammarterm{member-specification} of
|
2658 | 2658 | the class definition.
|
2659 | 2659 | \begin{note}
|
|
2673 | 2673 | \begin{note}
|
2674 | 2674 | A static member function does not have a \tcode{this}
|
2675 | 2675 | pointer\iref{expr.prim.this}.
|
2676 |
| -A static member function cannot be qualified with \tcode{const}, |
2677 |
| -\tcode{volatile}, or \tcode{virtual}\iref{dcl.fct}. |
| 2676 | +A static member function cannot be qualified with \keyword{const}, |
| 2677 | +\tcode{volatile}, or \keyword{virtual}\iref{dcl.fct}. |
2678 | 2678 | \end{note}
|
2679 | 2679 |
|
2680 | 2680 | \rSec3[class.static.data]{Static data members}
|
|
2688 | 2688 | the objects of the class.
|
2689 | 2689 |
|
2690 | 2690 | \pnum
|
2691 |
| -A static data member shall not be \tcode{mutable}\iref{dcl.stc}. |
| 2691 | +A static data member shall not be \keyword{mutable}\iref{dcl.stc}. |
2692 | 2692 | A static data member shall not be a direct member\iref{class.mem}
|
2693 | 2693 | of an unnamed\iref{class.pre} or local\iref{class.local} class or
|
2694 | 2694 | of a (possibly indirectly) nested class\iref{class.nest} thereof.
|
|
2738 | 2738 | \end{note}
|
2739 | 2739 |
|
2740 | 2740 | \pnum
|
2741 |
| -If a non-volatile non-inline \tcode{const} static data member is |
| 2741 | +If a non-volatile non-inline \keyword{const} static data member is |
2742 | 2742 | of integral or enumeration type,
|
2743 | 2743 | its declaration in the class definition can specify a
|
2744 | 2744 | \grammarterm{brace-or-equal-initializer} in which every
|
|
2828 | 2828 | A non-const reference shall not be bound to a
|
2829 | 2829 | bit-field\iref{dcl.init.ref}.
|
2830 | 2830 | \begin{note}
|
2831 |
| -If the initializer for a reference of type \tcode{const} \tcode{T\&} is |
| 2831 | +If the initializer for a reference of type \keyword{const} \tcode{T\&} is |
2832 | 2832 | an lvalue that refers to a bit-field, the reference is bound to a
|
2833 | 2833 | temporary initialized to hold the value of the bit-field; the reference
|
2834 | 2834 | is not bound to the bit-field directly. See~\ref{dcl.init.ref}.
|
|
3144 | 3144 | \indextext{\idxcode{union}!global anonymous}%
|
3145 | 3145 | \indextext{scope!anonymous \tcode{union} at namespace}%
|
3146 | 3146 | Anonymous unions declared in the scope of a namespace with external linkage
|
3147 |
| -shall be declared \tcode{static}. Anonymous unions declared at |
| 3147 | +shall be declared \keyword{static}. Anonymous unions declared at |
3148 | 3148 | block scope shall be declared with any storage class allowed for a
|
3149 | 3149 | block variable, or with no storage class. A storage class is not
|
3150 | 3150 | allowed in a declaration of an anonymous union in a class scope.
|
|
3489 | 3489 | \pnum
|
3490 | 3490 | \indextext{base class!virtual}%
|
3491 | 3491 | A base class specifier that does not contain the keyword
|
3492 |
| -\tcode{virtual} specifies a \defnadj{non-virtual}{base class}. A base |
3493 |
| -class specifier that contains the keyword \tcode{virtual} specifies a |
| 3492 | +\keyword{virtual} specifies a \defnadj{non-virtual}{base class}. A base |
| 3493 | +class specifier that contains the keyword \keyword{virtual} specifies a |
3494 | 3494 | \defnadj{virtual}{base class}. For each distinct occurrence of a
|
3495 | 3495 | non-virtual base class in the class lattice of the most derived class,
|
3496 | 3496 | the most derived object\iref{intro.object} shall contain a
|
|
3540 | 3540 | \end{importgraphic}
|
3541 | 3541 | For an object \tcode{c} of class type \tcode{C}, a single subobject of
|
3542 | 3542 | type \tcode{V} is shared by every base class subobject of \tcode{c} that has a
|
3543 |
| -\tcode{virtual} base class of type \tcode{V}. Given the class \tcode{C} |
| 3543 | +\keyword{virtual} base class of type \tcode{V}. Given the class \tcode{C} |
3544 | 3544 | defined above, an object of class \tcode{C} will have one subobject of
|
3545 | 3545 | class \tcode{V}, as shown in \fref{class.virt}.
|
3546 | 3546 | \indextext{DAG!multiple inheritance}%
|
|
3558 | 3558 | class Z : public B { @\commentellip@ };
|
3559 | 3559 | class AA : public X, public Y, public Z { @\commentellip@ };
|
3560 | 3560 | \end{codeblock}
|
3561 |
| -For an object of class \tcode{AA}, all \tcode{virtual} occurrences of |
| 3561 | +For an object of class \tcode{AA}, all \keyword{virtual} occurrences of |
3562 | 3562 | base class \tcode{B} in the class lattice of \tcode{AA} correspond to a
|
3563 | 3563 | single \tcode{B} subobject within the object of type \tcode{AA}, and
|
3564 | 3564 | every other occurrence of a (non-virtual) base class \tcode{B} in the
|
|
3584 | 3584 |
|
3585 | 3585 | \pnum
|
3586 | 3586 | A non-static member function is a \defnadj{virtual}{function}
|
3587 |
| -if it is first declared with the keyword \tcode{virtual} or |
| 3587 | +if it is first declared with the keyword \keyword{virtual} or |
3588 | 3588 | if it overrides a virtual member function declared in a base class
|
3589 | 3589 | (see below).
|
3590 | 3590 | \begin{footnote}
|
3591 |
| -The use of the \tcode{virtual} specifier in the |
| 3591 | +The use of the \keyword{virtual} specifier in the |
3592 | 3592 | declaration of an overriding function is valid but redundant (has empty
|
3593 | 3593 | semantics).
|
3594 | 3594 | \end{footnote}
|
|
3813 | 3813 |
|
3814 | 3814 | \pnum
|
3815 | 3815 | \begin{note}
|
3816 |
| -The \tcode{virtual} specifier implies membership, so a virtual function |
| 3816 | +The \keyword{virtual} specifier implies membership, so a virtual function |
3817 | 3817 | cannot be a non-member\iref{dcl.fct.spec} function. Nor can a virtual
|
3818 | 3818 | function be a static member, since a virtual function call relies on a
|
3819 | 3819 | specific object for determining which function to invoke. A virtual
|
|
4733 | 4733 | (\ref{temp.pre}, \ref{temp.friend}).
|
4734 | 4734 | \end{note}
|
4735 | 4735 | If the
|
4736 |
| -type specifier in a \tcode{friend} declaration designates a (possibly |
| 4736 | +type specifier in a \keyword{friend} declaration designates a (possibly |
4737 | 4737 | cv-qualified) class type, that class is declared as a friend; otherwise, the
|
4738 | 4738 | friend declaration is ignored.
|
4739 | 4739 | \begin{example}
|
|
6380 | 6380 | has the same \grammarterm{parameter-declaration-clause} and
|
6381 | 6381 | trailing \grammarterm{requires-clause} as
|
6382 | 6382 | the respective three-way comparison operator.
|
6383 |
| -It is declared with \tcode{friend}, \tcode{virtual}, \keyword{constexpr}, |
| 6383 | +It is declared with \keyword{friend}, \keyword{virtual}, \keyword{constexpr}, |
6384 | 6384 | or \keyword{consteval} if
|
6385 | 6385 | the three-way comparison operator function is so declared.
|
6386 | 6386 | If the three-way comparison operator function
|
|
6635 | 6635 | Any allocation function for a class
|
6636 | 6636 | \tcode{T}
|
6637 | 6637 | is a static member (even if not explicitly declared
|
6638 |
| -\tcode{static}). |
| 6638 | +\keyword{static}). |
6639 | 6639 |
|
6640 | 6640 | \pnum
|
6641 | 6641 | \begin{example}
|
|
6661 | 6661 | Any deallocation function for a class
|
6662 | 6662 | \tcode{X}
|
6663 | 6663 | is a static member (even if not explicitly declared
|
6664 |
| -\tcode{static}). |
| 6664 | +\keyword{static}). |
6665 | 6665 | \begin{example}
|
6666 | 6666 | \begin{codeblock}
|
6667 | 6667 | class X {
|
|
6678 | 6678 |
|
6679 | 6679 | \pnum
|
6680 | 6680 | Since member allocation and deallocation functions are
|
6681 |
| -\tcode{static} |
| 6681 | +\keyword{static} |
6682 | 6682 | they cannot be virtual.
|
6683 | 6683 | \begin{note}
|
6684 | 6684 | However, when the
|
|
0 commit comments