Skip to content

Commit cdc80a3

Browse files
tkoeppezygoloid
authored andcommitted
CWG2293 Requirements for simple-template-id used as a class-name
1 parent 7327e8a commit cdc80a3

File tree

2 files changed

+43
-23
lines changed

2 files changed

+43
-23
lines changed

source/basic.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@
614614
\indextext{region!declarative}%
615615
\indextext{scope!potential}%
616616
\defn{declarative region}, which is the largest part of the program
617-
in which that name is \defn{valid}, that is, in which that name may
617+
in which that name is valid, that is, in which that name may
618618
be used as an unqualified name to refer to the same entity. In general,
619619
each particular name is valid only within some possibly discontiguous
620620
portion of program text called its \defn{scope}. To determine the

source/templates.tex

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,45 @@
962962
A \grammarterm{template-id} that names an alias template
963963
specialization is a \grammarterm{type-name}.
964964

965+
\pnum
966+
A \grammarterm{template-id} is \defnx{valid}{\idxgram{template-id}!valid} if
967+
\begin{itemize}
968+
\item
969+
there are at most as many arguments as there are parameters
970+
or a parameter is a template parameter pack\iref{temp.variadic},
971+
972+
\item
973+
there is an argument for each non-deducible non-pack parameter
974+
that does not have a default \grammarterm{template-argument},
975+
976+
\item
977+
each \grammarterm{template-argument} matches the corresponding
978+
\grammarterm{template-parameter}\iref{temp.arg},
979+
980+
\item
981+
substitution of each template argument into the following
982+
template parameters (if any) succeeds, and
983+
984+
\item
985+
if the \grammarterm{template-id} is non-dependent,
986+
the associated constraints are satisfied as specified in the next paragraph.
987+
\end{itemize}
988+
A \grammarterm{simple-template-id} shall be valid unless it names a
989+
function template specialization\iref{temp.deduct}.
990+
\begin{example}
991+
\begin{codeblock}
992+
template<class T, T::type n = 0> class X;
993+
struct S {
994+
using type = int;
995+
};
996+
using T1 = X<S, int, int>; // error: too many arguments
997+
using T2 = X<>; // error: no default argument for first template parameter
998+
using T3 = X<1>; // error: value \tcode{1} does not match type-parameter
999+
using T4 = X<int>; // error: substitution failure for second template parameter
1000+
using T5 = X<S>; // OK
1001+
\end{codeblock}
1002+
\end{example}
1003+
9651004
\pnum
9661005
When the \grammarterm{template-name}
9671006
of a \grammarterm{simple-template-id}
@@ -7026,30 +7065,11 @@
70267065
\end{example}
70277066

70287067
\pnum
7029-
When an explicit template argument list is specified, if the template
7030-
arguments are not compatible with the template parameter list or do
7031-
not result in a valid function type as described below, type
7032-
deduction fails. Specifically, the following steps are performed when
7033-
evaluating an explicitly specified template argument list with respect
7034-
to a given function template:
7035-
\begin{itemize}
7036-
\item If the specified template arguments do not match the template
7037-
parameters in
7038-
kind (i.e., type, non-type, template), or if there
7039-
are more arguments than there are parameters
7040-
and no parameter is a template parameter pack, or if there is not
7041-
an argument for each non-pack parameter,
7042-
type deduction fails.
7043-
7044-
\item If any non-type argument does not match the type of the
7045-
corresponding non-type
7046-
template parameter, and is not convertible to the type of the
7047-
corresponding non-type parameter as specified in~\ref{temp.arg.nontype},
7068+
When an explicit template argument list is specified, if the
7069+
given \grammarterm{template-id} is invalid\iref{temp.names},
70487070
type deduction fails.
7049-
7050-
\item The specified template argument values are substituted for the
7071+
The specified template argument values are substituted for the
70517072
corresponding template parameters as specified below.
7052-
\end{itemize}
70537073

70547074
\pnum
70557075
After this substitution is performed, the function parameter type

0 commit comments

Comments
 (0)