From c7d8b0c3b9227a0e914e1edae230130d8f020f0d Mon Sep 17 00:00:00 2001 From: Jens Maurer Date: Thu, 12 Nov 2020 23:04:57 +0100 Subject: [PATCH 1/4] P0330R8 Literal Suffix for (signed) size_t --- source/lex.tex | 24 +++++++++++++++++++++++- source/preprocessor.tex | 1 + 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/source/lex.tex b/source/lex.tex index ccc68c2305..02e1aa07ba 100644 --- a/source/lex.tex +++ b/source/lex.tex @@ -1045,8 +1045,10 @@ \nontermdef{integer-suffix}\br unsigned-suffix \opt{long-suffix} \br unsigned-suffix \opt{long-long-suffix} \br + unsigned-suffix \opt{size-suffix} \br long-suffix \opt{unsigned-suffix} \br - long-long-suffix \opt{unsigned-suffix} + long-long-suffix \opt{unsigned-suffix} \br + size-suffix \opt{unsigned-suffix} \end{bnf} \begin{bnf} @@ -1064,6 +1066,11 @@ \terminal{ll LL} \end{bnf} +\begin{bnf} +\nontermdef{size-suffix} \textnormal{one of}\br + \terminal{z Z} +\end{bnf} + \pnum \indextext{literal!\idxcode{unsigned}}% \indextext{literal!\idxcode{long}}% @@ -1177,6 +1184,21 @@ \tcode{unsigned long long int} & \tcode{unsigned long long int}\\ and \tcode{ll} or \tcode{LL} & + & + \\\hline +\tcode{z} or \tcode{Z} & + the signed integer type corresponding & + the signed integer type \\ + & + \qquad to \tcode{std::size_t}\iref{support.types.layout} & + \qquad corresponding to \tcode{std::size_t} \\ + & + & + \tcode{std::size_t}\\\hline +Both \tcode{u} or \tcode{U} & + \tcode{std::size_t} & + \tcode{std::size_t} \\ +and \tcode{z} or \tcode{Z} & & \\ \end{floattable} diff --git a/source/preprocessor.tex b/source/preprocessor.tex index 2c2d8586a7..20c962781a 100644 --- a/source/preprocessor.tex +++ b/source/preprocessor.tex @@ -1793,6 +1793,7 @@ \defnxname{cpp_ref_qualifiers} & \tcode{200710L} \\ \rowsep \defnxname{cpp_return_type_deduction} & \tcode{201304L} \\ \rowsep \defnxname{cpp_rvalue_references} & \tcode{200610L} \\ \rowsep +\defnxname{cpp_size_t_suffix} & \tcode{202011L} \\ \rowsep \defnxname{cpp_sized_deallocation} & \tcode{201309L} \\ \rowsep \defnxname{cpp_static_assert} & \tcode{201411L} \\ \rowsep \defnxname{cpp_structured_bindings} & \tcode{201606L} \\ \rowsep From 3334ff2cd5affcc1ea1b3efd46c618f928275d3c Mon Sep 17 00:00:00 2001 From: Jens Maurer Date: Fri, 13 Nov 2020 00:15:04 +0100 Subject: [PATCH 2/4] P2096R2 Generalized wording for partial specializations --- source/declarations.tex | 6 +- source/templates.tex | 131 +++++++++++++++++----------------------- 2 files changed, 59 insertions(+), 78 deletions(-) diff --git a/source/declarations.tex b/source/declarations.tex index 1e0534a75b..dc6e37062b 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -7920,9 +7920,9 @@ \pnum \begin{note} -Partial specializations of class templates are found by looking up the -primary class template and then considering all partial specializations -of that template. If a \grammarterm{using-declaration} names a class +Partial specializations of templates are found by looking up the +primary template and then considering all partial specializations +of that template. If a \grammarterm{using-declaration} names a template, partial specializations introduced after the \grammarterm{using-declaration} are effectively visible because the primary template is visible\iref{temp.class.spec}. diff --git a/source/templates.tex b/source/templates.tex index 0ed61850f7..92b5eded7f 100644 --- a/source/templates.tex +++ b/source/templates.tex @@ -119,11 +119,11 @@ \begin{note} That last component can be an \grammarterm{identifier}, an \grammarterm{operator-function-id}, a \grammarterm{conversion-function-id}, or a \grammarterm{literal-operator-id}. In -a class template declaration, if the -class name +a class or variable template declaration, if the +declared name is a \grammarterm{simple-template-id}, -the declaration declares a class template partial specialization\iref{temp.class.spec}. +the declaration declares a partial specialization\iref{temp.class.spec}. \end{note} \pnum @@ -142,8 +142,8 @@ a template that has internal linkage are distinct from all specializations in other translation units. -A template, a template explicit specialization\iref{temp.expl.spec}, and a class -template partial specialization shall not have C linkage. Use of a linkage specification +A template, an explicit specialization\iref{temp.expl.spec}, and a +partial specialization shall not have C linkage. Use of a linkage specification other than \tcode{"C"} or \tcode{"C++"} with any of these constructs is conditionally-supported, with \impldef{semantics of linkage specification on templates} semantics. @@ -1315,15 +1315,14 @@ \grammarterm{template-parameter} shall be the name of a class template or an alias template, expressed as \grammarterm{id-expression}. -When the \grammarterm{template-argument} names a class -template, only primary class templates are considered when matching the template template +Only primary templates are considered when matching the template template argument with the corresponding parameter; partial specializations are not considered even if their parameter lists match that of the template template parameter. \pnum Any partial specializations\iref{temp.class.spec} associated with the -primary class template or primary variable template are considered when a +primary template are considered when a specialization based on the template \grammarterm{template-parameter} is instantiated. @@ -2163,21 +2162,10 @@ \rSec2[temp.decls.general]{General} \pnum -A -\grammarterm{template-id}, -that is, the -\grammarterm{template-name} -followed by a -\grammarterm{template-argument-list} -shall not be specified in the declaration of a primary template declaration. -\begin{example} -\begin{codeblock} -template class A { }; // error -template void sort(T1 data[I]); // error -\end{codeblock} -\end{example} \begin{note} -However, this syntax is allowed in class template partial specializations\iref{temp.class.spec}. +A \grammarterm{template-id} +cannot be the declared name of a primary template declaration. +However, this syntax is allowed in partial specializations\iref{temp.class.spec}. \end{note} \pnum @@ -3183,38 +3171,34 @@ Such a constrained friend function or function template declaration does not declare the same function or function template as a declaration in any other scope. -\rSec2[temp.class.spec]{Class template partial specializations} +\rSec2[temp.class.spec]{Partial specialization} \rSec3[temp.class.spec.general]{General} \pnum \indextext{specialization!class template partial}% \indextext{primary class template|see{template, primary}}% -A -\defnx{primary class template}{template!primary} -declaration is one in which the class template name is an -identifier. -A template declaration in which the class template name is a +A \defnadj{primary}{template} declaration +is one in which the name of the template +is not followed by a \grammarterm{template-argument-list}. +A template declaration in which the template name is a \grammarterm{simple-template-id} -is a -\defnx{partial specialization}{specialization!class template partial} -of the class template named in the -\grammarterm{simple-template-id}. -A partial specialization of a class template provides an alternative definition +is a \defnadj{partial}{specialization} +of the template named in the \grammarterm{simple-template-id}, +which shall be a class or variable template. +A partial specialization of a template provides an alternative definition of the template that is used instead of the primary definition when the arguments in a specialization match those given in the partial specialization\iref{temp.class.spec.match}. -The primary template shall be declared before any specializations of +The primary template shall be declared before any partial specializations of that template. -A partial specialization shall be declared before the first use of a class template +A partial specialization shall be declared before the first use of a template specialization that would make use of the partial specialization as the result of an implicit or explicit instantiation in every translation unit in which such a use occurs; no diagnostic is required. \pnum -Each class template partial specialization is a distinct template and -definitions shall be provided for the members of a template partial -specialization\iref{temp.class.spec.mfunc}. +Each partial specialization is a distinct template. \pnum \begin{example} @@ -3232,7 +3216,7 @@ \end{example} \pnum -A class template partial specialization may be constrained\iref{temp.pre}. +A partial specialization may be constrained\iref{temp.constr}. \begin{example} \begin{codeblock} template concept C = true; @@ -3250,15 +3234,12 @@ \end{example} \pnum -The template parameters are specified in the angle bracket enclosed list -that immediately follows the keyword -\keyword{template}. +The template parameters of a template are specified in the angle bracket enclosed list +that immediately follows the keyword \keyword{template}. For partial specializations, the template argument list is explicitly -written immediately following the class template name. +written immediately following the template name. For primary templates, this list is implicitly described by the -template parameter list. -Specifically, the order of the template arguments is the sequence in -which they appear in the template parameter list. +template parameter list\iref{temp.dep.type}. \begin{example} The template argument list for the primary template in the example above is @@ -3278,7 +3259,7 @@ \end{note} \pnum -A class template partial specialization may be declared in any +A partial specialization may be declared in any scope in which the corresponding primary template may be defined~(\ref{namespace.memdef}, \ref{class.mem}, \ref{temp.mem}). \begin{example} @@ -3302,12 +3283,13 @@ Partial specialization declarations themselves are not found by name lookup. Rather, when the primary template name is used, any previously-declared partial specializations of the primary template are also considered. +\begin{note} One consequence is -that a -\grammarterm{using-declaration} +that a \grammarterm{using-declaration} which refers to a class template does not restrict the set of partial specializations which may be found through the \grammarterm{using-declaration}. +\end{note} \begin{example} \begin{codeblock} namespace N { @@ -3331,13 +3313,13 @@ All other non-type arguments are specialized. \pnum -Within the argument list of a class template partial specialization, +Within the argument list of a partial specialization, the following restrictions apply: \begin{itemize} \item The type of a template parameter corresponding to a specialized non-type argument -shall not be dependent on a parameter of the specialization. +shall not be dependent on a parameter of the partial specialization. \begin{example} \begin{codeblock} template struct C {}; @@ -3350,11 +3332,11 @@ \end{example} \item -The specialization shall be more specialized than the primary +The partial specialization shall be more specialized than the primary template\iref{temp.class.order}. \item -The template parameter list of a specialization shall not contain default +The template parameter list of a partial specialization shall not contain default template argument values. \begin{footnote} There is no context in which they would be used. @@ -3376,29 +3358,29 @@ but will be checked when substituting into the partial specialization. \end{note} -\rSec3[temp.class.spec.match]{Matching of class template partial specializations} +\rSec3[temp.class.spec.match]{Matching of partial specializations} \pnum -When a class template is used in a context that requires an instantiation of -the class, +When a template is used in a context that requires an instantiation of +the template, it is necessary to determine whether the instantiation is to be generated using the primary template or one of the partial specializations. -This is done by matching the template arguments of the class template +This is done by matching the template arguments of the template specialization with the template argument lists of the partial specializations. \begin{itemize} \item -If exactly one matching specialization is found, the instantiation is -generated from that specialization. +If exactly one matching partial specialization is found, the instantiation is +generated from that partial specialization. \item -If more than one matching specialization is found, +If more than one matching partial specialization is found, the partial order rules\iref{temp.class.order} are used to determine -whether one of the specializations is more specialized than the +whether one of the partial specializations is more specialized than the others. -If none of the specializations is more specialized than all of the -other matching specializations, then the use of the class template -is ambiguous and the program is ill-formed. +If such a partial specialization exists, +the instantiation is generated from that partial specialization; +otherwise, the use of the template is ambiguous and the program is ill-formed. \item If no matches are found, the instantiation is generated from the primary template. @@ -3457,18 +3439,18 @@ \end{example} \pnum -In a type name that refers to a class template specialization, (e.g., -\tcode{A}) +In a name that refers to a specialization of a class or variable template +(e.g., \tcode{A}), the argument list shall match the template parameter list of the primary template. -The template arguments of a specialization are deduced from the arguments +The template arguments of a partial specialization are deduced from the arguments of the primary template. -\rSec3[temp.class.order]{Partial ordering of class template specializations} +\rSec3[temp.class.order]{Partial ordering of partial specializations} \pnum \indextext{more specialized!class template}% -For two class template partial specializations, +For two partial specializations, the first is \defn{more specialized} than the second if, given the following rewrite to two function templates, the first function template is more specialized than the second according to the ordering rules for function @@ -3540,7 +3522,7 @@ because \tcode{B} is more specialized than \tcode{A}. \end{example} -\rSec3[temp.class.spec.mfunc]{Members of class template specializations} +\rSec3[temp.class.spec.mfunc]{Members of class template partial specializations} \pnum The template parameter list of a member of a class template partial @@ -3549,7 +3531,6 @@ The template argument list of a member of a class template partial specialization shall match the template argument list of the class template partial specialization. -A class template partial specialization is a distinct template. The members of the class template partial specialization are unrelated to the members of the primary template. Class template partial specialization members that are used in a way that @@ -3558,7 +3539,7 @@ template partial specialization. An explicit specialization of a member of a class template partial specialization is declared in the same way as an explicit specialization of -the primary template. +a member of the primary template. \begin{example} \begin{codeblock} // primary class template @@ -4289,7 +4270,7 @@ A concept cannot be explicitly instantiated\iref{temp.explicit}, explicitly specialized\iref{temp.expl.spec}, -or partially specialized. +or partially specialized\iref{temp.class.spec}. \end{note} \pnum @@ -5072,8 +5053,8 @@ the name of the nested class referenced as a member of the current instantiation, or \item -in the definition of a partial specialization -or a member of a partial specialization, the name of +in the definition of a class template partial specialization +or a member of a class template partial specialization, the name of the class template followed by the template argument list of the partial specialization enclosed in \tcode{<>} (or an equivalent template alias specialization). From 2d442fea8c2a61379810cb8e243acf954c54d881 Mon Sep 17 00:00:00 2001 From: Jens Maurer Date: Fri, 13 Nov 2020 00:18:49 +0100 Subject: [PATCH 3/4] Rename stable labels "temp.class.spec*" to "temp.spec.partial*" This follows the generalization of the notion of "partial specialization" from P2096R2, which made the old labels somewhat inaccurate, and was recommended as an option by that paper. --- source/classes.tex | 2 +- source/declarations.tex | 6 +++--- source/templates.tex | 30 +++++++++++++++--------------- source/xrefdelta.tex | 7 +++++++ 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/source/classes.tex b/source/classes.tex index 58c298f81b..37eb220522 100644 --- a/source/classes.tex +++ b/source/classes.tex @@ -60,7 +60,7 @@ A class declaration where the \grammarterm{class-name} in the \grammarterm{class-head-name} is a \grammarterm{simple-template-id} shall be an explicit specialization\iref{temp.expl.spec} or -a partial specialization\iref{temp.class.spec}. +a partial specialization\iref{temp.spec.partial}. A \grammarterm{class-specifier} whose \grammarterm{class-head} omits the \grammarterm{class-head-name} defines an unnamed class. diff --git a/source/declarations.tex b/source/declarations.tex index dc6e37062b..f87d5f69c3 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -7192,7 +7192,7 @@ namespace is implicitly inserted into the enclosing namespace as for an unnamed namespace\iref{namespace.unnamed}. Furthermore, each member of the inline namespace can subsequently be partially -specialized\iref{temp.class.spec}, explicitly +specialized\iref{temp.spec.partial}, explicitly instantiated\iref{temp.explicit}, or explicitly specialized\iref{temp.expl.spec} as though it were a member of the enclosing namespace. Finally, looking up a name in the enclosing namespace via explicit qualification\iref{namespace.qual} will include @@ -7893,7 +7893,7 @@ considered when a use of the name is made. Thus, additional overloads added after the \grammarterm{using-declaration} are ignored, but default function arguments\iref{dcl.fct.default}, default template -arguments\iref{temp.param}, and template specializations~(\ref{temp.class.spec}, +arguments\iref{temp.param}, and template specializations~(\ref{temp.spec.partial}, \ref{temp.expl.spec}) are considered. \end{note} \begin{example} @@ -7925,7 +7925,7 @@ of that template. If a \grammarterm{using-declaration} names a template, partial specializations introduced after the \grammarterm{using-declaration} are effectively visible because the primary -template is visible\iref{temp.class.spec}. +template is visible\iref{temp.spec.partial}. \end{note} \pnum diff --git a/source/templates.tex b/source/templates.tex index 92b5eded7f..f16be83673 100644 --- a/source/templates.tex +++ b/source/templates.tex @@ -123,7 +123,7 @@ declared name is a \grammarterm{simple-template-id}, -the declaration declares a partial specialization\iref{temp.class.spec}. +the declaration declares a partial specialization\iref{temp.spec.partial}. \end{note} \pnum @@ -157,7 +157,7 @@ \pnum A class template shall not have the same name as any other template, class, function, variable, enumeration, enumerator, namespace, or -type in the same scope\iref{basic.scope}, except as specified in~\ref{temp.class.spec}. +type in the same scope\iref{basic.scope}, except as specified in~\ref{temp.spec.partial}. Except that a function template can be overloaded either by non-template functions\iref{dcl.fct} with the same name or by other function templates with the same name\iref{temp.over}, @@ -1321,7 +1321,7 @@ parameter. \pnum -Any partial specializations\iref{temp.class.spec} associated with the +Any partial specializations\iref{temp.spec.partial} associated with the primary template are considered when a specialization based on the template \grammarterm{template-parameter} @@ -1991,7 +1991,7 @@ \item the best viable candidate of non-template functions\iref{over.match.best}, \item the address of a non-template function\iref{over.over}, \item the matching of template template arguments\iref{temp.arg.template}, -\item the partial ordering of class template specializations\iref{temp.class.order}, and +\item the partial ordering of class template specializations\iref{temp.spec.partial.order}, and \item the partial ordering of function templates\iref{temp.func.order}. \end{itemize} \end{note} @@ -2165,7 +2165,7 @@ \begin{note} A \grammarterm{template-id} cannot be the declared name of a primary template declaration. -However, this syntax is allowed in partial specializations\iref{temp.class.spec}. +However, this syntax is allowed in partial specializations\iref{temp.spec.partial}. \end{note} \pnum @@ -3067,7 +3067,7 @@ \pnum A template friend declaration specifies that all specializations of that template, whether they are implicitly instantiated\iref{temp.inst}, partially -specialized\iref{temp.class.spec} or explicitly specialized\iref{temp.expl.spec}, +specialized\iref{temp.spec.partial} or explicitly specialized\iref{temp.expl.spec}, are friends of the class containing the template friend declaration. \begin{example} \begin{codeblock} @@ -3171,9 +3171,9 @@ Such a constrained friend function or function template declaration does not declare the same function or function template as a declaration in any other scope. -\rSec2[temp.class.spec]{Partial specialization} +\rSec2[temp.spec.partial]{Partial specialization} -\rSec3[temp.class.spec.general]{General} +\rSec3[temp.spec.partial.general]{General} \pnum \indextext{specialization!class template partial}% @@ -3189,7 +3189,7 @@ A partial specialization of a template provides an alternative definition of the template that is used instead of the primary definition when the arguments in a specialization match those given in the partial -specialization\iref{temp.class.spec.match}. +specialization\iref{temp.spec.partial.match}. The primary template shall be declared before any partial specializations of that template. A partial specialization shall be declared before the first use of a template @@ -3333,7 +3333,7 @@ \end{example} \item The partial specialization shall be more specialized than the primary -template\iref{temp.class.order}. +template\iref{temp.spec.partial.order}. \item The template parameter list of a partial specialization shall not contain default @@ -3358,7 +3358,7 @@ but will be checked when substituting into the partial specialization. \end{note} -\rSec3[temp.class.spec.match]{Matching of partial specializations} +\rSec3[temp.spec.partial.match]{Matching of partial specializations} \pnum When a template is used in a context that requires an instantiation of @@ -3375,7 +3375,7 @@ generated from that partial specialization. \item If more than one matching partial specialization is found, -the partial order rules\iref{temp.class.order} are used to determine +the partial order rules\iref{temp.spec.partial.order} are used to determine whether one of the partial specializations is more specialized than the others. If such a partial specialization exists, @@ -3446,7 +3446,7 @@ The template arguments of a partial specialization are deduced from the arguments of the primary template. -\rSec3[temp.class.order]{Partial ordering of partial specializations} +\rSec3[temp.spec.partial.order]{Partial ordering of partial specializations} \pnum \indextext{more specialized!class template}% @@ -3522,7 +3522,7 @@ because \tcode{B} is more specialized than \tcode{A}. \end{example} -\rSec3[temp.class.spec.mfunc]{Members of class template partial specializations} +\rSec3[temp.spec.partial.member]{Members of class template partial specializations} \pnum The template parameter list of a member of a class template partial @@ -4270,7 +4270,7 @@ A concept cannot be explicitly instantiated\iref{temp.explicit}, explicitly specialized\iref{temp.expl.spec}, -or partially specialized\iref{temp.class.spec}. +or partially specialized\iref{temp.spec.partial}. \end{note} \pnum diff --git a/source/xrefdelta.tex b/source/xrefdelta.tex index 7b6af45f59..18cf3fdfff 100644 --- a/source/xrefdelta.tex +++ b/source/xrefdelta.tex @@ -25,5 +25,12 @@ \movedxref{re.def}{intro.refs} +% P2096R2 Generalized wording for partial specializations +\movedxref{temp.class.spec}{temp.spec.partial} +\movedxref{temp.class.spec.general}{temp.spec.partial.general} +\movedxref{temp.class.spec.match}{temp.spec.partial.match} +\movedxref{temp.class.order}{temp.spec.partial.order} +\movedxref{temp.class.spec.mfunc}{temp.spec.partial.member} + % Deprecated features. %\deprxref{old.label} (if moved to depr.old.label, otherwise use \movedxref) From 2625d87d5820b32b471bd347ec2fe01127a5f652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20K=C3=B6ppe?= Date: Thu, 26 Nov 2020 11:55:28 +0000 Subject: [PATCH 4/4] [temp.spec.partial.general] Reword note to avoid "may" --- source/templates.tex | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/templates.tex b/source/templates.tex index f16be83673..393853b6e3 100644 --- a/source/templates.tex +++ b/source/templates.tex @@ -3287,8 +3287,7 @@ One consequence is that a \grammarterm{using-declaration} which refers to a class template does not restrict the set of partial specializations -which may be found through the -\grammarterm{using-declaration}. +that are found through the \grammarterm{using-declaration}. \end{note} \begin{example} \begin{codeblock}