[clang] [clang] Enable C++17 relaxed template template argument matching by default (PR #89807)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 26 02:33:51 PDT 2024


================
@@ -507,10 +507,62 @@ static TemplateDeductionResult DeduceNonTypeTemplateArgument(
       S, TemplateParams, NTTP, DeducedTemplateArgument(New), T, Info, Deduced);
 }
 
+static NamedDecl *DeduceTemplateArguments(Sema &S, NamedDecl *A,
+                                          TemplateArgument Default) {
+  switch (A->getKind()) {
+  case Decl::TemplateTypeParm: {
+    auto *T = cast<TemplateTypeParmDecl>(A);
+    // FIXME: DefaultArgument can't represent a pack.
+    if (T->isParameterPack())
----------------
mizvekov wrote:

I see.

The code I posted was an attempt to construct such an example, where a pack doesn't need to be defaulted as-written for the proposed changes in the rules to have an effect. Except that example hits the wall at something else first, and I haven't fully investigated that. I haven't excluded the possibility that such an example could be constructed yet.

So when I proposed that provisional wording, I didn't exclude packs from the equation. I don't see a reason to, as without excluding them, the rules stay simpler and more general and should still work.

If we want to exclude them for implementation efficiency reasons, we could, as presumably it could still work as-if.

https://github.com/llvm/llvm-project/pull/89807


More information about the cfe-commits mailing list