Skip to content

Commit e66f7ce

Browse files
committed
Merge 2020-11 CWG Motion 3
P2096R2 Generalized wording for partial specializations
2 parents 7fcf9dd + 2625d87 commit e66f7ce

File tree

4 files changed

+79
-92
lines changed

4 files changed

+79
-92
lines changed

source/classes.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
A class declaration where the \grammarterm{class-name}
6161
in the \grammarterm{class-head-name} is a \grammarterm{simple-template-id}
6262
shall be an explicit specialization\iref{temp.expl.spec} or
63-
a partial specialization\iref{temp.class.spec}.
63+
a partial specialization\iref{temp.spec.partial}.
6464
A \grammarterm{class-specifier} whose
6565
\grammarterm{class-head} omits the
6666
\grammarterm{class-head-name} defines an unnamed class.

source/declarations.tex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7192,7 +7192,7 @@
71927192
namespace is implicitly inserted into the enclosing namespace as for an unnamed
71937193
namespace\iref{namespace.unnamed}. Furthermore, each
71947194
member of the inline namespace can subsequently be partially
7195-
specialized\iref{temp.class.spec}, explicitly
7195+
specialized\iref{temp.spec.partial}, explicitly
71967196
instantiated\iref{temp.explicit}, or explicitly specialized\iref{temp.expl.spec} as
71977197
though it were a member of the enclosing namespace. Finally, looking up a name in the
71987198
enclosing namespace via explicit qualification\iref{namespace.qual} will include
@@ -7893,7 +7893,7 @@
78937893
considered when a use of the name is made. Thus, additional
78947894
overloads added after the \grammarterm{using-declaration} are ignored, but
78957895
default function arguments\iref{dcl.fct.default}, default template
7896-
arguments\iref{temp.param}, and template specializations~(\ref{temp.class.spec},
7896+
arguments\iref{temp.param}, and template specializations~(\ref{temp.spec.partial},
78977897
\ref{temp.expl.spec}) are considered.
78987898
\end{note}
78997899
\begin{example}
@@ -7920,12 +7920,12 @@
79207920

79217921
\pnum
79227922
\begin{note}
7923-
Partial specializations of class templates are found by looking up the
7924-
primary class template and then considering all partial specializations
7925-
of that template. If a \grammarterm{using-declaration} names a class
7923+
Partial specializations of templates are found by looking up the
7924+
primary template and then considering all partial specializations
7925+
of that template. If a \grammarterm{using-declaration} names a
79267926
template, partial specializations introduced after the
79277927
\grammarterm{using-declaration} are effectively visible because the primary
7928-
template is visible\iref{temp.class.spec}.
7928+
template is visible\iref{temp.spec.partial}.
79297929
\end{note}
79307930

79317931
\pnum

source/templates.tex

Lines changed: 65 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@
119119
\begin{note}
120120
That last component can be an \grammarterm{identifier}, an \grammarterm{operator-function-id},
121121
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
124124
is a
125125
\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}.
127127
\end{note}
128128

129129
\pnum
@@ -142,8 +142,8 @@
142142
a template that has internal linkage are
143143
distinct from all specializations in other translation
144144
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
147147
other than \tcode{"C"} or \tcode{"C++"} with any of these constructs is
148148
conditionally-supported, with
149149
\impldef{semantics of linkage specification on templates} semantics.
@@ -157,7 +157,7 @@
157157
\pnum
158158
A class template shall not have the same name as any other
159159
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}.
161161
Except that a function template can be overloaded either by non-template
162162
functions\iref{dcl.fct} with the same name or by other function templates
163163
with the same name\iref{temp.over},
@@ -1315,15 +1315,14 @@
13151315
\grammarterm{template-parameter}
13161316
shall be the name of a class template or an alias template, expressed as
13171317
\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
13201319
argument with the corresponding parameter; partial specializations are not
13211320
considered even if their parameter lists match that of the template template
13221321
parameter.
13231322

13241323
\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
13271326
specialization based on the template
13281327
\grammarterm{template-parameter}
13291328
is instantiated.
@@ -1992,7 +1991,7 @@
19921991
\item the best viable candidate of non-template functions\iref{over.match.best},
19931992
\item the address of a non-template function\iref{over.over},
19941993
\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
19961995
\item the partial ordering of function templates\iref{temp.func.order}.
19971996
\end{itemize}
19981997
\end{note}
@@ -2163,21 +2162,10 @@
21632162
\rSec2[temp.decls.general]{General}
21642163

21652164
\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}
21792165
\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}.
21812169
\end{note}
21822170

21832171
\pnum
@@ -3079,7 +3067,7 @@
30793067
\pnum
30803068
A template friend declaration specifies that all specializations of that
30813069
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},
30833071
are friends of the class containing the template friend declaration.
30843072
\begin{example}
30853073
\begin{codeblock}
@@ -3183,38 +3171,34 @@
31833171
Such a constrained friend function or function template declaration
31843172
does not declare the same function or function template as a declaration in any other scope.
31853173

3186-
\rSec2[temp.class.spec]{Class template partial specializations}
3174+
\rSec2[temp.spec.partial]{Partial specialization}
31873175

3188-
\rSec3[temp.class.spec.general]{General}
3176+
\rSec3[temp.spec.partial.general]{General}
31893177

31903178
\pnum
31913179
\indextext{specialization!class template partial}%
31923180
\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
31983185
\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
32043190
of the template that is used instead of the primary definition when the
32053191
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
32083194
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
32103196
specialization that would make use of the partial specialization as the result of
32113197
an implicit or explicit instantiation in every translation unit in which such a use
32123198
occurs; no diagnostic is required.
32133199

32143200
\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.
32183202

32193203
\pnum
32203204
\begin{example}
@@ -3232,7 +3216,7 @@
32323216
\end{example}
32333217

32343218
\pnum
3235-
A class template partial specialization may be constrained\iref{temp.pre}.
3219+
A partial specialization may be constrained\iref{temp.constr}.
32363220
\begin{example}
32373221
\begin{codeblock}
32383222
template<typename T> concept C = true;
@@ -3250,15 +3234,12 @@
32503234
\end{example}
32513235

32523236
\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}.
32563239
For partial specializations, the template argument list is explicitly
3257-
written immediately following the class template name.
3240+
written immediately following the template name.
32583241
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}.
32623243
\begin{example}
32633244
The template argument list for the primary template in the example
32643245
above is
@@ -3278,7 +3259,7 @@
32783259
\end{note}
32793260

32803261
\pnum
3281-
A class template partial specialization may be declared in any
3262+
A partial specialization may be declared in any
32823263
scope in which the corresponding primary template
32833264
may be defined~(\ref{namespace.memdef}, \ref{class.mem}, \ref{temp.mem}).
32843265
\begin{example}
@@ -3302,12 +3283,12 @@
33023283
Partial specialization declarations themselves are not found by name lookup.
33033284
Rather, when the primary template name is used, any previously-declared partial
33043285
specializations of the primary template are also considered.
3286+
\begin{note}
33053287
One consequence is
3306-
that a
3307-
\grammarterm{using-declaration}
3288+
that a \grammarterm{using-declaration}
33083289
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}
33113292
\begin{example}
33123293
\begin{codeblock}
33133294
namespace N {
@@ -3331,13 +3312,13 @@
33313312
All other non-type arguments are specialized.
33323313

33333314
\pnum
3334-
Within the argument list of a class template partial specialization,
3315+
Within the argument list of a partial specialization,
33353316
the following restrictions apply:
33363317

33373318
\begin{itemize}
33383319
\item
33393320
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.
33413322
\begin{example}
33423323
\begin{codeblock}
33433324
template <class T, T t> struct C {};
@@ -3350,11 +3331,11 @@
33503331

33513332
\end{example}
33523333
\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}.
33553336

33563337
\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
33583339
template argument values.
33593340
\begin{footnote}
33603341
There is no context in which they would be used.
@@ -3376,29 +3357,29 @@
33763357
but will be checked when substituting into the partial specialization.
33773358
\end{note}
33783359

3379-
\rSec3[temp.class.spec.match]{Matching of class template partial specializations}
3360+
\rSec3[temp.spec.partial.match]{Matching of partial specializations}
33803361

33813362
\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,
33843365
it is necessary to determine whether the instantiation is to be generated
33853366
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
33873368
specialization with the template argument lists of the partial
33883369
specializations.
33893370

33903371
\begin{itemize}
33913372
\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.
33943375
\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
33983379
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.
34023383
\item
34033384
If no matches are found, the instantiation is generated from the
34043385
primary template.
@@ -3457,18 +3438,18 @@
34573438
\end{example}
34583439

34593440
\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>}),
34623443
the argument list shall match the template parameter list of the primary
34633444
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
34653446
of the primary template.
34663447

3467-
\rSec3[temp.class.order]{Partial ordering of class template specializations}
3448+
\rSec3[temp.spec.partial.order]{Partial ordering of partial specializations}
34683449

34693450
\pnum
34703451
\indextext{more specialized!class template}%
3471-
For two class template partial specializations,
3452+
For two partial specializations,
34723453
the first is \defn{more specialized} than the second if, given the following
34733454
rewrite to two function templates, the first function template is more
34743455
specialized than the second according to the ordering rules for function
@@ -3540,7 +3521,7 @@
35403521
because \tcode{B} is more specialized than \tcode{A}.
35413522
\end{example}
35423523

3543-
\rSec3[temp.class.spec.mfunc]{Members of class template specializations}
3524+
\rSec3[temp.spec.partial.member]{Members of class template partial specializations}
35443525

35453526
\pnum
35463527
The template parameter list of a member of a class template partial
@@ -3549,7 +3530,6 @@
35493530
The template argument list of a member of a class template partial
35503531
specialization shall match the template argument list of the class template
35513532
partial specialization.
3552-
A class template partial specialization is a distinct template.
35533533
The members of the class template partial specialization are
35543534
unrelated to the members of the primary template.
35553535
Class template partial specialization members that are used in a way that
@@ -3558,7 +3538,7 @@
35583538
template partial specialization.
35593539
An explicit specialization of a member of a class template partial
35603540
specialization is declared in the same way as an explicit specialization of
3561-
the primary template.
3541+
a member of the primary template.
35623542
\begin{example}
35633543
\begin{codeblock}
35643544
// primary class template
@@ -4289,7 +4269,7 @@
42894269
A concept cannot be
42904270
explicitly instantiated\iref{temp.explicit},
42914271
explicitly specialized\iref{temp.expl.spec},
4292-
or partially specialized.
4272+
or partially specialized\iref{temp.spec.partial}.
42934273
\end{note}
42944274

42954275
\pnum
@@ -5072,8 +5052,8 @@
50725052
the name of the nested class referenced as a member of the
50735053
current instantiation, or
50745054
\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
50775057
the class template followed by the template argument list of
50785058
the partial specialization enclosed in
50795059
\tcode{<>} (or an equivalent template alias specialization).

0 commit comments

Comments
 (0)