Skip to content

Commit 732c095

Browse files
committed
P3865R3 Class template argument deduction (CTAD) for type template template
1 parent fda5e37 commit 732c095

File tree

3 files changed

+47
-4
lines changed

3 files changed

+47
-4
lines changed

source/declarations.tex

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,16 +1444,24 @@
14441444
if any, shall be non-dependent and
14451445
the \grammarterm{template-name} or \grammarterm{splice-specifier}
14461446
shall designate a deducible template.
1447-
A \defnadj{deducible}{template} is either a class template or
1448-
is an alias template whose \grammarterm{defining-type-id} is of the form
1447+
A \defnadj{deducible}{template} is
1448+
\begin{itemize}
1449+
\item
1450+
a class template,
1451+
\item
1452+
a type template template parameter, or
1453+
\item
1454+
an alias template \tcode{A} whose \grammarterm{defining-type-id} is of the form
14491455

14501456
\begin{ncsimplebnf}
14511457
\opt{\keyword{typename}} \opt{nested-name-specifier} \opt{\keyword{template}} simple-template-id
14521458
\end{ncsimplebnf}
14531459

14541460
where the \grammarterm{nested-name-specifier} (if any) is non-dependent and
14551461
the \grammarterm{template-name} of the \grammarterm{simple-template-id}
1456-
names a deducible template.
1462+
names a deducible template
1463+
other than a type template template parameter of \tcode{A}.
1464+
\end{itemize}
14571465
\begin{note}
14581466
An injected-class-name is never interpreted as a \grammarterm{template-name}
14591467
in contexts where class template argument deduction would be performed\iref{temp.local}.

source/overloading.tex

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,6 +1431,20 @@
14311431
\end{codeblock}
14321432
\end{example}
14331433

1434+
\pnum
1435+
When resolving a placeholder for a deduced class type
1436+
where the \grammarterm{template-name}
1437+
designates a type template template parameter \tcode{P},
1438+
the type template template argument for \tcode{P}
1439+
shall be a deducible template.
1440+
Let \tcode{A} be an alias template
1441+
whose template parameter list is that of \tcode{P} and
1442+
whose \grammarterm{defining-type-id} is a \grammarterm{simple-template-id}
1443+
whose \grammarterm{template-name} designates the type template template argument and
1444+
whose \grammarterm{template-argument-list} is the template argument list of \tcode{P}.
1445+
\tcode{A} is then used instead of the original \grammarterm{template-name}
1446+
to resolve the placeholder.
1447+
14341448
\pnum
14351449
When resolving a placeholder for a deduced class type\iref{dcl.type.simple}
14361450
where
@@ -1688,6 +1702,25 @@
16881702
\indextext{overloading!argument lists|)}%
16891703
\indextext{overloading!candidate functions|)}
16901704

1705+
\pnum
1706+
\begin{example}
1707+
\begin{codeblock}
1708+
template<typename ... Ts>
1709+
struct Y {
1710+
Y();
1711+
Y(Ts ...);
1712+
};
1713+
template<template<typename T = char> class X>
1714+
void f() {
1715+
X x; // OK, deduces \tcode{Y<char>}
1716+
X x0{}; // OK, deduces \tcode{Y<char>}
1717+
X x1{1}; // OK, deduces \tcode{Y<int>}
1718+
X x2{1, 2}; // error: cannot deduce \tcode{X<T>} from \tcode{Y<int, int>}
1719+
}
1720+
template void f<Y>();
1721+
\end{codeblock}
1722+
\end{example}
1723+
16911724
\rSec2[over.match.viable]{Viable functions}%
16921725
\indextext{overloading!resolution!viable functions|(}
16931726

source/templates.tex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5660,7 +5660,9 @@
56605660
is dependent if
56615661
\begin{itemize}
56625662
\item
5663-
it has a dependent initializer, or
5663+
it has a dependent initializer,
5664+
\item
5665+
it refers to a type template template parameter, or
56645666
\item
56655667
it refers to an alias template
56665668
that is a member of the current instantiation and

0 commit comments

Comments
 (0)