|
962 | 962 | A \grammarterm{template-id} that names an alias template
|
963 | 963 | specialization is a \grammarterm{type-name}.
|
964 | 964 |
|
| 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 | + |
965 | 1004 | \pnum
|
966 | 1005 | When the \grammarterm{template-name}
|
967 | 1006 | of a \grammarterm{simple-template-id}
|
|
7026 | 7065 | \end{example}
|
7027 | 7066 |
|
7028 | 7067 | \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}, |
7048 | 7070 | 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 |
7051 | 7072 | corresponding template parameters as specified below.
|
7052 |
| -\end{itemize} |
7053 | 7073 |
|
7054 | 7074 | \pnum
|
7055 | 7075 | After this substitution is performed, the function parameter type
|
|
0 commit comments