[clang] [Sema]Substitue parameter packs when deduced from function parameter (PR #79371)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 25 11:12:34 PST 2024


================
@@ -858,6 +859,27 @@ class PackDeductionScope {
       Info.PendingDeducedPacks[Pack.Index] = Pack.Outer;
   }
 
+  // Return the size of the saved packs if all of them has the same size.
+  std::optional<unsigned> getSavedPackSizeIfAllEqual() const {
+    if (Packs.size() == 0 ||
+        Packs[0].Saved.getKind() != clang::TemplateArgument::Pack)
+      return {};
+    unsigned PackSize = Packs[0].Saved.pack_size();
+
+    if (std::all_of(Packs.begin() + 1, Packs.end(), [&PackSize](auto P) {
----------------
erichkeane wrote:

```suggestion
    if (std::all_of(Packs.begin() + 1, Packs.end(), [&PackSize](const auto &P) {
```

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


More information about the cfe-commits mailing list