Skip to content

Commit 1d65b9b

Browse files
committed
CWG3032 Template argument disambiguation
1 parent e9ae510 commit 1d65b9b

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

source/templates.tex

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -715,10 +715,15 @@
715715

716716
\begin{bnf}
717717
\nontermdef{template-argument}\br
718+
template-argument-name\br
718719
constant-expression\br
719-
type-id\br
720-
\opt{nested-name-specifier} template-name\br
721-
nested-name-specifier \terminal{template} template-name
720+
type-id
721+
\end{bnf}
722+
723+
\begin{bnf}
724+
\nontermdef{template-argument-name}\br
725+
\opt{nested-name-specifier} identifier\br
726+
nested-name-specifier \terminal{template} identifier
722727
\end{bnf}
723728

724729
\pnum
@@ -888,6 +893,11 @@
888893
\end{codeblock}
889894
\end{example}
890895

896+
\pnum
897+
The component names of a \grammarterm{template-argument-name} are
898+
those of its \grammarterm{nested-name-specifier} (if any) and
899+
its \grammarterm{identifier}.
900+
891901
\pnum
892902
A \grammarterm{template-id} or \grammarterm{splice-specialization-specifier}
893903
is \defnx{valid}{\idxgram{template-id}!valid} if
@@ -1051,6 +1061,29 @@
10511061
the $n^\text{th}$ template argument is a pack expansion
10521062
whose pattern is the name of the template parameter pack.
10531063

1064+
\pnum
1065+
If a \grammarterm{template-argument} $A$
1066+
matches the form \grammarterm{template-argument-name},
1067+
it is interpreted as such;
1068+
the identifier is looked up and its meaning is determined as follows:
1069+
\begin{itemize}
1070+
\item
1071+
If lookup finds an injected-class-name\iref{temp.local}, then:
1072+
\begin{itemize}
1073+
\item When $A$ is for a type template template parameter,
1074+
$A$ denotes the corresponding class template.
1075+
\item Otherwise, it denotes a \grammarterm{type-name}.
1076+
\end{itemize}
1077+
\item
1078+
Otherwise, if lookup finds a template,
1079+
$A$ denotes that template.
1080+
\item
1081+
Otherwise, if lookup finds a type alias or a type,
1082+
$A$ denotes the underlying type and is interpreted as a \grammarterm{type-id}.
1083+
\item
1084+
Otherwise, $A$ is interpreted as an expression.
1085+
\end{itemize}
1086+
10541087
\pnum
10551088
In a
10561089
\grammarterm{template-argument},

0 commit comments

Comments
 (0)