|
119 | 119 | \begin{note}
|
120 | 120 | That last component can be an \grammarterm{identifier}, an \grammarterm{operator-function-id},
|
121 | 121 | a \grammarterm{conversion-function-id}, or a \grammarterm{literal-operator-id}. In
|
122 |
| -a class template declaration, if the |
123 |
| -class name |
| 122 | +a class or variable template declaration, if the |
| 123 | +declared name |
124 | 124 | is a
|
125 | 125 | \grammarterm{simple-template-id},
|
126 |
| -the declaration declares a class template partial specialization\iref{temp.class.spec}. |
| 126 | +the declaration declares a partial specialization\iref{temp.spec.partial}. |
127 | 127 | \end{note}
|
128 | 128 |
|
129 | 129 | \pnum
|
|
142 | 142 | a template that has internal linkage are
|
143 | 143 | distinct from all specializations in other translation
|
144 | 144 | units.
|
145 |
| -A template, a template explicit specialization\iref{temp.expl.spec}, and a class |
146 |
| -template partial specialization shall not have C linkage. Use of a linkage specification |
| 145 | +A template, an explicit specialization\iref{temp.expl.spec}, and a |
| 146 | +partial specialization shall not have C linkage. Use of a linkage specification |
147 | 147 | other than \tcode{"C"} or \tcode{"C++"} with any of these constructs is
|
148 | 148 | conditionally-supported, with
|
149 | 149 | \impldef{semantics of linkage specification on templates} semantics.
|
|
157 | 157 | \pnum
|
158 | 158 | A class template shall not have the same name as any other
|
159 | 159 | template, class, function, variable, enumeration, enumerator, namespace, or
|
160 |
| -type in the same scope\iref{basic.scope}, except as specified in~\ref{temp.class.spec}. |
| 160 | +type in the same scope\iref{basic.scope}, except as specified in~\ref{temp.spec.partial}. |
161 | 161 | Except that a function template can be overloaded either by non-template
|
162 | 162 | functions\iref{dcl.fct} with the same name or by other function templates
|
163 | 163 | with the same name\iref{temp.over},
|
|
1315 | 1315 | \grammarterm{template-parameter}
|
1316 | 1316 | shall be the name of a class template or an alias template, expressed as
|
1317 | 1317 | \grammarterm{id-expression}.
|
1318 |
| -When the \grammarterm{template-argument} names a class |
1319 |
| -template, only primary class templates are considered when matching the template template |
| 1318 | +Only primary templates are considered when matching the template template |
1320 | 1319 | argument with the corresponding parameter; partial specializations are not
|
1321 | 1320 | considered even if their parameter lists match that of the template template
|
1322 | 1321 | parameter.
|
1323 | 1322 |
|
1324 | 1323 | \pnum
|
1325 |
| -Any partial specializations\iref{temp.class.spec} associated with the |
1326 |
| -primary class template or primary variable template are considered when a |
| 1324 | +Any partial specializations\iref{temp.spec.partial} associated with the |
| 1325 | +primary template are considered when a |
1327 | 1326 | specialization based on the template
|
1328 | 1327 | \grammarterm{template-parameter}
|
1329 | 1328 | is instantiated.
|
|
1992 | 1991 | \item the best viable candidate of non-template functions\iref{over.match.best},
|
1993 | 1992 | \item the address of a non-template function\iref{over.over},
|
1994 | 1993 | \item the matching of template template arguments\iref{temp.arg.template},
|
1995 |
| -\item the partial ordering of class template specializations\iref{temp.class.order}, and |
| 1994 | +\item the partial ordering of class template specializations\iref{temp.spec.partial.order}, and |
1996 | 1995 | \item the partial ordering of function templates\iref{temp.func.order}.
|
1997 | 1996 | \end{itemize}
|
1998 | 1997 | \end{note}
|
|
2163 | 2162 | \rSec2[temp.decls.general]{General}
|
2164 | 2163 |
|
2165 | 2164 | \pnum
|
2166 |
| -A |
2167 |
| -\grammarterm{template-id}, |
2168 |
| -that is, the |
2169 |
| -\grammarterm{template-name} |
2170 |
| -followed by a |
2171 |
| -\grammarterm{template-argument-list} |
2172 |
| -shall not be specified in the declaration of a primary template declaration. |
2173 |
| -\begin{example} |
2174 |
| -\begin{codeblock} |
2175 |
| -template<class T1, class T2, int I> class A<T1, T2, I> { }; // error |
2176 |
| -template<class T1, int I> void sort<T1, I>(T1 data[I]); // error |
2177 |
| -\end{codeblock} |
2178 |
| -\end{example} |
2179 | 2165 | \begin{note}
|
2180 |
| -However, this syntax is allowed in class template partial specializations\iref{temp.class.spec}. |
| 2166 | +A \grammarterm{template-id} |
| 2167 | +cannot be the declared name of a primary template declaration. |
| 2168 | +However, this syntax is allowed in partial specializations\iref{temp.spec.partial}. |
2181 | 2169 | \end{note}
|
2182 | 2170 |
|
2183 | 2171 | \pnum
|
|
3079 | 3067 | \pnum
|
3080 | 3068 | A template friend declaration specifies that all specializations of that
|
3081 | 3069 | template, whether they are implicitly instantiated\iref{temp.inst}, partially
|
3082 |
| -specialized\iref{temp.class.spec} or explicitly specialized\iref{temp.expl.spec}, |
| 3070 | +specialized\iref{temp.spec.partial} or explicitly specialized\iref{temp.expl.spec}, |
3083 | 3071 | are friends of the class containing the template friend declaration.
|
3084 | 3072 | \begin{example}
|
3085 | 3073 | \begin{codeblock}
|
|
3183 | 3171 | Such a constrained friend function or function template declaration
|
3184 | 3172 | does not declare the same function or function template as a declaration in any other scope.
|
3185 | 3173 |
|
3186 |
| -\rSec2[temp.class.spec]{Class template partial specializations} |
| 3174 | +\rSec2[temp.spec.partial]{Partial specialization} |
3187 | 3175 |
|
3188 |
| -\rSec3[temp.class.spec.general]{General} |
| 3176 | +\rSec3[temp.spec.partial.general]{General} |
3189 | 3177 |
|
3190 | 3178 | \pnum
|
3191 | 3179 | \indextext{specialization!class template partial}%
|
3192 | 3180 | \indextext{primary class template|see{template, primary}}%
|
3193 |
| -A |
3194 |
| -\defnx{primary class template}{template!primary} |
3195 |
| -declaration is one in which the class template name is an |
3196 |
| -identifier. |
3197 |
| -A template declaration in which the class template name is a |
| 3181 | +A \defnadj{primary}{template} declaration |
| 3182 | +is one in which the name of the template |
| 3183 | +is not followed by a \grammarterm{template-argument-list}. |
| 3184 | +A template declaration in which the template name is a |
3198 | 3185 | \grammarterm{simple-template-id}
|
3199 |
| -is a |
3200 |
| -\defnx{partial specialization}{specialization!class template partial} |
3201 |
| -of the class template named in the |
3202 |
| -\grammarterm{simple-template-id}. |
3203 |
| -A partial specialization of a class template provides an alternative definition |
| 3186 | +is a \defnadj{partial}{specialization} |
| 3187 | +of the template named in the \grammarterm{simple-template-id}, |
| 3188 | +which shall be a class or variable template. |
| 3189 | +A partial specialization of a template provides an alternative definition |
3204 | 3190 | of the template that is used instead of the primary definition when the
|
3205 | 3191 | arguments in a specialization match those given in the partial
|
3206 |
| -specialization\iref{temp.class.spec.match}. |
3207 |
| -The primary template shall be declared before any specializations of |
| 3192 | +specialization\iref{temp.spec.partial.match}. |
| 3193 | +The primary template shall be declared before any partial specializations of |
3208 | 3194 | that template.
|
3209 |
| -A partial specialization shall be declared before the first use of a class template |
| 3195 | +A partial specialization shall be declared before the first use of a template |
3210 | 3196 | specialization that would make use of the partial specialization as the result of
|
3211 | 3197 | an implicit or explicit instantiation in every translation unit in which such a use
|
3212 | 3198 | occurs; no diagnostic is required.
|
3213 | 3199 |
|
3214 | 3200 | \pnum
|
3215 |
| -Each class template partial specialization is a distinct template and |
3216 |
| -definitions shall be provided for the members of a template partial |
3217 |
| -specialization\iref{temp.class.spec.mfunc}. |
| 3201 | +Each partial specialization is a distinct template. |
3218 | 3202 |
|
3219 | 3203 | \pnum
|
3220 | 3204 | \begin{example}
|
|
3232 | 3216 | \end{example}
|
3233 | 3217 |
|
3234 | 3218 | \pnum
|
3235 |
| -A class template partial specialization may be constrained\iref{temp.pre}. |
| 3219 | +A partial specialization may be constrained\iref{temp.constr}. |
3236 | 3220 | \begin{example}
|
3237 | 3221 | \begin{codeblock}
|
3238 | 3222 | template<typename T> concept C = true;
|
|
3250 | 3234 | \end{example}
|
3251 | 3235 |
|
3252 | 3236 | \pnum
|
3253 |
| -The template parameters are specified in the angle bracket enclosed list |
3254 |
| -that immediately follows the keyword |
3255 |
| -\keyword{template}. |
| 3237 | +The template parameters of a template are specified in the angle bracket enclosed list |
| 3238 | +that immediately follows the keyword \keyword{template}. |
3256 | 3239 | For partial specializations, the template argument list is explicitly
|
3257 |
| -written immediately following the class template name. |
| 3240 | +written immediately following the template name. |
3258 | 3241 | For primary templates, this list is implicitly described by the
|
3259 |
| -template parameter list. |
3260 |
| -Specifically, the order of the template arguments is the sequence in |
3261 |
| -which they appear in the template parameter list. |
| 3242 | +template parameter list\iref{temp.dep.type}. |
3262 | 3243 | \begin{example}
|
3263 | 3244 | The template argument list for the primary template in the example
|
3264 | 3245 | above is
|
|
3278 | 3259 | \end{note}
|
3279 | 3260 |
|
3280 | 3261 | \pnum
|
3281 |
| -A class template partial specialization may be declared in any |
| 3262 | +A partial specialization may be declared in any |
3282 | 3263 | scope in which the corresponding primary template
|
3283 | 3264 | may be defined~(\ref{namespace.memdef}, \ref{class.mem}, \ref{temp.mem}).
|
3284 | 3265 | \begin{example}
|
|
3302 | 3283 | Partial specialization declarations themselves are not found by name lookup.
|
3303 | 3284 | Rather, when the primary template name is used, any previously-declared partial
|
3304 | 3285 | specializations of the primary template are also considered.
|
| 3286 | +\begin{note} |
3305 | 3287 | One consequence is
|
3306 |
| -that a |
3307 |
| -\grammarterm{using-declaration} |
| 3288 | +that a \grammarterm{using-declaration} |
3308 | 3289 | which refers to a class template does not restrict the set of partial specializations
|
3309 |
| -which may be found through the |
3310 |
| -\grammarterm{using-declaration}. |
| 3290 | +that are found through the \grammarterm{using-declaration}. |
| 3291 | +\end{note} |
3311 | 3292 | \begin{example}
|
3312 | 3293 | \begin{codeblock}
|
3313 | 3294 | namespace N {
|
|
3331 | 3312 | All other non-type arguments are specialized.
|
3332 | 3313 |
|
3333 | 3314 | \pnum
|
3334 |
| -Within the argument list of a class template partial specialization, |
| 3315 | +Within the argument list of a partial specialization, |
3335 | 3316 | the following restrictions apply:
|
3336 | 3317 |
|
3337 | 3318 | \begin{itemize}
|
3338 | 3319 | \item
|
3339 | 3320 | The type of a template parameter corresponding to a specialized non-type argument
|
3340 |
| -shall not be dependent on a parameter of the specialization. |
| 3321 | +shall not be dependent on a parameter of the partial specialization. |
3341 | 3322 | \begin{example}
|
3342 | 3323 | \begin{codeblock}
|
3343 | 3324 | template <class T, T t> struct C {};
|
|
3350 | 3331 |
|
3351 | 3332 | \end{example}
|
3352 | 3333 | \item
|
3353 |
| -The specialization shall be more specialized than the primary |
3354 |
| -template\iref{temp.class.order}. |
| 3334 | +The partial specialization shall be more specialized than the primary |
| 3335 | +template\iref{temp.spec.partial.order}. |
3355 | 3336 |
|
3356 | 3337 | \item
|
3357 |
| -The template parameter list of a specialization shall not contain default |
| 3338 | +The template parameter list of a partial specialization shall not contain default |
3358 | 3339 | template argument values.
|
3359 | 3340 | \begin{footnote}
|
3360 | 3341 | There is no context in which they would be used.
|
|
3376 | 3357 | but will be checked when substituting into the partial specialization.
|
3377 | 3358 | \end{note}
|
3378 | 3359 |
|
3379 |
| -\rSec3[temp.class.spec.match]{Matching of class template partial specializations} |
| 3360 | +\rSec3[temp.spec.partial.match]{Matching of partial specializations} |
3380 | 3361 |
|
3381 | 3362 | \pnum
|
3382 |
| -When a class template is used in a context that requires an instantiation of |
3383 |
| -the class, |
| 3363 | +When a template is used in a context that requires an instantiation of |
| 3364 | +the template, |
3384 | 3365 | it is necessary to determine whether the instantiation is to be generated
|
3385 | 3366 | using the primary template or one of the partial specializations.
|
3386 |
| -This is done by matching the template arguments of the class template |
| 3367 | +This is done by matching the template arguments of the template |
3387 | 3368 | specialization with the template argument lists of the partial
|
3388 | 3369 | specializations.
|
3389 | 3370 |
|
3390 | 3371 | \begin{itemize}
|
3391 | 3372 | \item
|
3392 |
| -If exactly one matching specialization is found, the instantiation is |
3393 |
| -generated from that specialization. |
| 3373 | +If exactly one matching partial specialization is found, the instantiation is |
| 3374 | +generated from that partial specialization. |
3394 | 3375 | \item
|
3395 |
| -If more than one matching specialization is found, |
3396 |
| -the partial order rules\iref{temp.class.order} are used to determine |
3397 |
| -whether one of the specializations is more specialized than the |
| 3376 | +If more than one matching partial specialization is found, |
| 3377 | +the partial order rules\iref{temp.spec.partial.order} are used to determine |
| 3378 | +whether one of the partial specializations is more specialized than the |
3398 | 3379 | others.
|
3399 |
| -If none of the specializations is more specialized than all of the |
3400 |
| -other matching specializations, then the use of the class template |
3401 |
| -is ambiguous and the program is ill-formed. |
| 3380 | +If such a partial specialization exists, |
| 3381 | +the instantiation is generated from that partial specialization; |
| 3382 | +otherwise, the use of the template is ambiguous and the program is ill-formed. |
3402 | 3383 | \item
|
3403 | 3384 | If no matches are found, the instantiation is generated from the
|
3404 | 3385 | primary template.
|
|
3457 | 3438 | \end{example}
|
3458 | 3439 |
|
3459 | 3440 | \pnum
|
3460 |
| -In a type name that refers to a class template specialization, (e.g., |
3461 |
| -\tcode{A<int, int, 1>}) |
| 3441 | +In a name that refers to a specialization of a class or variable template |
| 3442 | +(e.g., \tcode{A<int, int, 1>}), |
3462 | 3443 | the argument list shall match the template parameter list of the primary
|
3463 | 3444 | template.
|
3464 |
| -The template arguments of a specialization are deduced from the arguments |
| 3445 | +The template arguments of a partial specialization are deduced from the arguments |
3465 | 3446 | of the primary template.
|
3466 | 3447 |
|
3467 |
| -\rSec3[temp.class.order]{Partial ordering of class template specializations} |
| 3448 | +\rSec3[temp.spec.partial.order]{Partial ordering of partial specializations} |
3468 | 3449 |
|
3469 | 3450 | \pnum
|
3470 | 3451 | \indextext{more specialized!class template}%
|
3471 |
| -For two class template partial specializations, |
| 3452 | +For two partial specializations, |
3472 | 3453 | the first is \defn{more specialized} than the second if, given the following
|
3473 | 3454 | rewrite to two function templates, the first function template is more
|
3474 | 3455 | specialized than the second according to the ordering rules for function
|
|
3540 | 3521 | because \tcode{B} is more specialized than \tcode{A}.
|
3541 | 3522 | \end{example}
|
3542 | 3523 |
|
3543 |
| -\rSec3[temp.class.spec.mfunc]{Members of class template specializations} |
| 3524 | +\rSec3[temp.spec.partial.member]{Members of class template partial specializations} |
3544 | 3525 |
|
3545 | 3526 | \pnum
|
3546 | 3527 | The template parameter list of a member of a class template partial
|
|
3549 | 3530 | The template argument list of a member of a class template partial
|
3550 | 3531 | specialization shall match the template argument list of the class template
|
3551 | 3532 | partial specialization.
|
3552 |
| -A class template partial specialization is a distinct template. |
3553 | 3533 | The members of the class template partial specialization are
|
3554 | 3534 | unrelated to the members of the primary template.
|
3555 | 3535 | Class template partial specialization members that are used in a way that
|
|
3558 | 3538 | template partial specialization.
|
3559 | 3539 | An explicit specialization of a member of a class template partial
|
3560 | 3540 | specialization is declared in the same way as an explicit specialization of
|
3561 |
| -the primary template. |
| 3541 | +a member of the primary template. |
3562 | 3542 | \begin{example}
|
3563 | 3543 | \begin{codeblock}
|
3564 | 3544 | // primary class template
|
|
4289 | 4269 | A concept cannot be
|
4290 | 4270 | explicitly instantiated\iref{temp.explicit},
|
4291 | 4271 | explicitly specialized\iref{temp.expl.spec},
|
4292 |
| -or partially specialized. |
| 4272 | +or partially specialized\iref{temp.spec.partial}. |
4293 | 4273 | \end{note}
|
4294 | 4274 |
|
4295 | 4275 | \pnum
|
|
5072 | 5052 | the name of the nested class referenced as a member of the
|
5073 | 5053 | current instantiation, or
|
5074 | 5054 | \item
|
5075 |
| -in the definition of a partial specialization |
5076 |
| -or a member of a partial specialization, the name of |
| 5055 | +in the definition of a class template partial specialization |
| 5056 | +or a member of a class template partial specialization, the name of |
5077 | 5057 | the class template followed by the template argument list of
|
5078 | 5058 | the partial specialization enclosed in
|
5079 | 5059 | \tcode{<>} (or an equivalent template alias specialization).
|
|
0 commit comments