|
319 | 319 | to be a
|
320 | 320 | \grammarterm{typedef-name}
|
321 | 321 | (if declared without
|
322 |
| -\tcode{template}) |
| 322 | +\keyword{template}) |
323 | 323 | or
|
324 | 324 | \grammarterm{template-name}
|
325 | 325 | (if declared with
|
326 |
| -\tcode{template}) |
| 326 | +\keyword{template}) |
327 | 327 | in the scope of the template declaration.
|
328 | 328 | \begin{note}
|
329 | 329 | A template argument may be a class template or alias template.
|
|
764 | 764 | \end{example}
|
765 | 765 |
|
766 | 766 | \pnum
|
767 |
| -The keyword \tcode{template} is said to appear at the top level in |
| 767 | +The keyword \keyword{template} is said to appear at the top level in |
768 | 768 | a \grammarterm{qualified-id}
|
769 | 769 | if it appears outside of a \grammarterm{template-argument-list} or
|
770 | 770 | \grammarterm{decltype-specifier}.
|
771 | 771 | In a \grammarterm{qualified-id} of a \grammarterm{declarator-id} or
|
772 | 772 | in a \grammarterm{qualified-id} formed by a \grammarterm{class-head-name}\iref{class.pre} or
|
773 | 773 | \grammarterm{enum-head-name}\iref{dcl.enum},
|
774 |
| -the keyword \tcode{template} shall not appear at the top level. |
| 774 | +the keyword \keyword{template} shall not appear at the top level. |
775 | 775 | In a \grammarterm{qualified-id} used as the name in a
|
776 | 776 | \grammarterm{typename-specifier}\iref{temp.res},
|
777 | 777 | \grammarterm{elaborated-type-specifier}\iref{dcl.type.elab},
|
778 | 778 | \grammarterm{using-declaration}\iref{namespace.udecl}, or
|
779 | 779 | \grammarterm{class-or-decltype}\iref{class.derived},
|
780 |
| -an optional keyword \tcode{template} appearing at the top level is ignored. |
| 780 | +an optional keyword \keyword{template} appearing at the top level is ignored. |
781 | 781 | In these contexts, a \tcode{<} token is always assumed to introduce a
|
782 | 782 | \grammarterm{template-argument-list}.
|
783 | 783 | In all other contexts, when naming a template specialization of
|
784 | 784 | a member of an unknown specialization\iref{temp.dep.type},
|
785 |
| -the member template name shall be prefixed by the keyword \tcode{template}. |
| 785 | +the member template name shall be prefixed by the keyword \keyword{template}. |
786 | 786 | \begin{example}
|
787 | 787 | \begin{codeblock}
|
788 | 788 | struct X {
|
|
800 | 800 |
|
801 | 801 | \pnum
|
802 | 802 | A name prefixed by the keyword
|
803 |
| -\tcode{template} |
| 803 | +\keyword{template} |
804 | 804 | shall be a \grammarterm{template-id} or
|
805 | 805 | the name shall refer to a class template or an alias template.
|
806 | 806 | \begin{note}
|
807 | 807 | The keyword
|
808 |
| -\tcode{template} |
| 808 | +\keyword{template} |
809 | 809 | may not be applied to non-template members of class templates.
|
810 | 810 | \end{note}
|
811 | 811 | \begin{note}
|
812 | 812 | As is the case with the
|
813 | 813 | \tcode{typename}
|
814 | 814 | prefix, the
|
815 |
| -\tcode{template} |
| 815 | +\keyword{template} |
816 | 816 | prefix is allowed in cases where it is not strictly
|
817 | 817 | necessary; i.e., when the \grammarterm{nested-name-specifier} or
|
818 | 818 | the expression on the left of
|
|
2245 | 2245 | T& elem(int i) { return v[i]; }
|
2246 | 2246 | };
|
2247 | 2247 | \end{codeblock}
|
2248 |
| -The prefix \tcode{template<class T>} |
| 2248 | +The prefix \tcode{\keyword{template}<class T>} |
2249 | 2249 | specifies that a template is being declared and that a
|
2250 | 2250 | \grammarterm{type-name}
|
2251 | 2251 | \tcode{T}
|
|
3255 | 3255 | \pnum
|
3256 | 3256 | The template parameters are specified in the angle bracket enclosed list
|
3257 | 3257 | that immediately follows the keyword
|
3258 |
| -\tcode{template}. |
| 3258 | +\keyword{template}. |
3259 | 3259 | For partial specializations, the template argument list is explicitly
|
3260 | 3260 | written immediately following the class template name.
|
3261 | 3261 | For primary templates, this list is implicitly described by the
|
|
5991 | 5991 | a variable template, a class template, a member of a class template, or
|
5992 | 5992 | a member template.
|
5993 | 5993 | An explicit specialization declaration is introduced by
|
5994 |
| -\tcode{template<>}. |
| 5994 | +\tcode{\keyword{template}<>}. |
5995 | 5995 | In an explicit specialization declaration for
|
5996 | 5996 | a variable template, a class template,
|
5997 | 5997 | a member of a class template or a class member template,
|
|
6839 | 6839 | member function template of a class or class template
|
6840 | 6840 | \end{itemize}
|
6841 | 6841 | can be declared by a declaration introduced by
|
6842 |
| -\tcode{template<>}; |
| 6842 | +\tcode{\keyword{template}<>}; |
6843 | 6843 | that is:
|
6844 | 6844 | \indextext{\idxgram{explicit-specialization}}%
|
6845 | 6845 |
|
|
6935 | 6935 | specialization.
|
6936 | 6936 | Members of an explicitly specialized
|
6937 | 6937 | class template are defined in the same manner as members of normal classes, and
|
6938 |
| -not using the \tcode{template<>} syntax. |
| 6938 | +not using the \tcode{\keyword{template}<>} syntax. |
6939 | 6939 | The same is true when defining a member of an explicitly specialized member
|
6940 |
| -class. However, \tcode{template<>} is used in defining a member of an explicitly |
| 6940 | +class. However, \tcode{\keyword{template}<>} is used in defining a member of an explicitly |
6941 | 6941 | specialized member class template that is specialized as a class template.
|
6942 | 6942 | \begin{example}
|
6943 | 6943 | \begin{codeblock}
|
|
6955 | 6955 | a.f(16); // \tcode{A<int>::f} must be defined somewhere
|
6956 | 6956 | }
|
6957 | 6957 |
|
6958 |
| -// \tcode{template<>} not used for a member of an explicitly specialized class template |
| 6958 | +// \tcode{\keyword{template}<>} not used for a member of an explicitly specialized class template |
6959 | 6959 | void A<int>::f(int) { @\commentellip@ }
|
6960 | 6960 |
|
6961 | 6961 | template<> struct A<char>::B {
|
6962 | 6962 | void f();
|
6963 | 6963 | };
|
6964 |
| -// \tcode{template<>} also not used when defining a member of an explicitly specialized member class |
| 6964 | +// \tcode{\keyword{template}<>} also not used when defining a member of an explicitly specialized member class |
6965 | 6965 | void A<char>::B::f() { @\commentellip@ }
|
6966 | 6966 |
|
6967 | 6967 | template<> template<class U> struct A<char>::C {
|
6968 | 6968 | void f();
|
6969 | 6969 | };
|
6970 |
| -// \tcode{template<>} is used when defining a member of an explicitly specialized member class template |
| 6970 | +// \tcode{\keyword{template}<>} is used when defining a member of an explicitly specialized member class template |
6971 | 6971 | // specialized as a class template
|
6972 | 6972 | template<>
|
6973 | 6973 | template<class U> void A<char>::C<U>::f() { @\commentellip@ }
|
6974 | 6974 |
|
6975 | 6975 | template<> struct A<short>::B {
|
6976 | 6976 | void f();
|
6977 | 6977 | };
|
6978 |
| -template<> void A<short>::B::f() { @\commentellip@ } // error: \tcode{template<>} not permitted |
| 6978 | +template<> void A<short>::B::f() { @\commentellip@ } // error: \tcode{\keyword{template}<>} not permitted |
6979 | 6979 |
|
6980 | 6980 | template<> template<class U> struct A<short>::C {
|
6981 | 6981 | void f();
|
6982 | 6982 | };
|
6983 |
| -template<class U> void A<short>::C<U>::f() { @\commentellip@ } // error: \tcode{template<>} required |
| 6983 | +template<class U> void A<short>::C<U>::f() { @\commentellip@ } // error: \tcode{\keyword{template}<>} required |
6984 | 6984 | \end{codeblock}
|
6985 | 6985 | \end{example}
|
6986 | 6986 |
|
|
7185 | 7185 | templates.
|
7186 | 7186 | In an explicit specialization for such a member,
|
7187 | 7187 | the member declaration shall be preceded by a
|
7188 |
| -\tcode{template<>} |
| 7188 | +\tcode{\keyword{template}<>} |
7189 | 7189 | for each enclosing class template that is explicitly specialized.
|
7190 | 7190 | \begin{example}
|
7191 | 7191 | \begin{codeblock}
|
|
7208 | 7208 | template if its enclosing class templates are not explicitly specialized
|
7209 | 7209 | as well.
|
7210 | 7210 | In such an explicit specialization declaration, the keyword
|
7211 |
| -\tcode{template} |
| 7211 | +\keyword{template} |
7212 | 7212 | followed by a
|
7213 | 7213 | \grammarterm{template-parameter-list}
|
7214 | 7214 | shall be provided instead of the
|
7215 |
| -\tcode{template<>} |
| 7215 | +\tcode{\keyword{template}<>} |
7216 | 7216 | preceding the explicit specialization declaration of the member.
|
7217 | 7217 | The types of the
|
7218 | 7218 | \grammarterm{template-parameter}{s}
|
|
0 commit comments