[llvm-branch-commits] [clang] [clang] Finish implementation of P0522 (PR #96023)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Jun 19 02:42:37 PDT 2024
================
@@ -2513,49 +2545,76 @@ DeduceTemplateArguments(Sema &S, TemplateParameterList *TemplateParams,
TemplateDeductionInfo &Info,
SmallVectorImpl<DeducedTemplateArgument> &Deduced,
bool NumberOfArgumentsMustMatch, PackFold PackFold) {
- if (PackFold == PackFold::ArgumentToParameter)
- std::swap(Ps, As);
+ bool FoldPackParameter = PackFold == PackFold::ParameterToArgument ||
+ PackFold == PackFold::Both,
+ FoldPackArgument = PackFold == PackFold::ArgumentToParameter ||
+ PackFold == PackFold::Both;
+
// C++0x [temp.deduct.type]p9:
// If the template argument list of P contains a pack expansion that is not
// the last template argument, the entire template argument list is a
// non-deduced context.
- if (hasPackExpansionBeforeEnd(Ps))
+ if (FoldPackParameter && hasPackExpansionBeforeEnd(Ps))
+ return TemplateDeductionResult::Success;
+
+ if (FoldPackArgument && hasPackExpansionBeforeEnd(As))
return TemplateDeductionResult::Success;
// C++0x [temp.deduct.type]p9:
// If P has a form that contains <T> or <i>, then each argument Pi of the
// respective template argument list P is compared with the corresponding
// argument Ai of the corresponding template argument list of A.
- unsigned ArgIdx = 0, ParamIdx = 0;
- for (; hasTemplateArgumentForDeduction(Ps, ParamIdx); ++ParamIdx) {
- const TemplateArgument &P = Ps[ParamIdx];
- if (!P.isPackExpansion()) {
+ for (unsigned ArgIdx = 0, ParamIdx = 0; /**/; /**/) {
+ if (!hasTemplateArgumentForDeduction(Ps, ParamIdx))
+ return !FoldPackParameter && NumberOfArgumentsMustMatch &&
+ hasTemplateArgumentForDeduction(As, ArgIdx) &&
+ !As[ArgIdx].isPackExpansion()
+ ? TemplateDeductionResult::MiscellaneousDeductionFailure
----------------
cor3ntin wrote:
Should that be `IncompletePack` (rather than `MiscellaneousDeductionFailure`)?
https://github.com/llvm/llvm-project/pull/96023
More information about the llvm-branch-commits
mailing list