[Bug c++/103313] nontype_argument_pack - compile error due to unsupported tree

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Dec 17 00:55:08 GMT 2024


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103313

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note this code was not valid as there is no way to deduce the template
arguments based on the default argument.

What you can do instead is do this (for C++20 though):
```
template <int I>
struct S {
    Q mq[I];
    void f(array<int, I> &a) {
      [&]<size_t ...num>(index_sequence<num...>) {
        ((mq[num].set(a[num])), ...);
      }(make_index_sequence<I>{});
    }
};
```

That is make an templated lambda to take the index_sequence to do the fold
expression.


More information about the Gcc-bugs mailing list