Skip to content

Commit a078888

Browse files
authored
Merge 2022-07 CWG Motion 16
P2582R1 Wording for class template argument deduction from inherited constructors.
2 parents e26d26e + b4d366d commit a078888

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

source/overloading.tex

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,69 @@
12741274
the trailing sequence of parameters corresponding
12751275
to a trailing aggregate element that is a pack expansion (if any)
12761276
is replaced by a single parameter of the form $\tcode{T}_n \tcode{...}$.
1277+
In addition,
1278+
if \tcode{C} is defined and
1279+
inherits constructors\iref{namespace.udecl}
1280+
from a direct base class denoted in the \grammarterm{base-specifier-list}
1281+
by a \grammarterm{class-or-decltype} \tcode{B},
1282+
let \tcode{A} be an alias template
1283+
whose template parameter list is that of \tcode{C} and
1284+
whose \grammarterm{defining-type-id} is \tcode{B}.
1285+
%% FIXME: the following sentence is very hard to follow; rewrite!
1286+
If \tcode{A} is a deducible template\iref{dcl.type.simple},
1287+
the set contains the guides of \tcode{A}
1288+
with the return type \tcode{R} of each guide
1289+
replaced with \tcode{typename CC<R>::type} given a class template
1290+
\begin{codeblock}
1291+
template <typename> class CC;
1292+
\end{codeblock}
1293+
whose primary template is not defined and
1294+
with a single partial specialization
1295+
whose template parameter list is that of \tcode{A} and
1296+
whose template argument list is a specialization of \tcode{A} with
1297+
the template argument list of \tcode{A}\iref{temp.dep.type}
1298+
having a member typedef \tcode{type} designating a template specialization with
1299+
the template argument list of \tcode{A} but
1300+
with \tcode{C} as the template.
1301+
\begin{note}
1302+
Equivalently,
1303+
the template parameter list of the specialization is that of \tcode{C},
1304+
the template argument list of the specialization is \tcode{B}, and
1305+
the member typedef names \tcode{C} with the template argument list of \tcode{C}.
1306+
\end{note}
1307+
1308+
\pnum
1309+
\begin{example}
1310+
\begin{codeblock}
1311+
template <typename T> struct B {
1312+
B(T);
1313+
};
1314+
template <typename T> struct C : public B<T> {
1315+
using B<T>::B;
1316+
};
1317+
template <typename T> struct D : public B<T> {};
1318+
1319+
C c(42); // OK, deduces \tcode{C<int>}
1320+
D d(42); // error: deduction failed, no inherited deduction guides
1321+
B(int) -> B<char>;
1322+
C c2(42); // OK, deduces \tcode{C<char>}
1323+
1324+
template <typename T> struct E : public B<int> {
1325+
using B<int>::B;
1326+
};
1327+
1328+
E e(42); // error: deduction failed, arguments of \tcode{E} cannot be deduced from introduced guides
1329+
1330+
template <typename T, typename U, typename V> struct F {
1331+
F(T, U, V);
1332+
};
1333+
template <typename T, typename U> struct G : F<U, T, int> {
1334+
using G::F::F;
1335+
}
1336+
1337+
G g(true, 'a', 1); // OK, deduces \tcode{G<char, bool>}
1338+
\end{codeblock}
1339+
\end{example}
12771340

12781341
\pnum
12791342
When resolving a placeholder for a deduced class type\iref{dcl.type.simple}
@@ -1741,6 +1804,18 @@
17411804
\end{example}
17421805
or, if not that
17431806

1807+
\item
1808+
\tcode{F1} and \tcode{F2} are generated
1809+
from class template argument deduction\iref{over.match.class.deduct}
1810+
for a class \tcode{D}, and
1811+
\tcode{F2} is generated
1812+
from inheriting constructors from a base class of \tcode{D}
1813+
while \tcode{F1} is not, and
1814+
for each explicit function argument,
1815+
the corresponding parameters of \tcode{F1} and \tcode{F2}
1816+
are either both ellipses or have the same type,
1817+
or, if not that,
1818+
17441819
\item
17451820
\tcode{F1} is generated from a
17461821
\grammarterm{deduction-guide}\iref{over.match.class.deduct}

0 commit comments

Comments
 (0)