I tried to replicate your code and fix it with no success.
I think this question may have the answers, and explained in a pretty newb-friendly way (I know because I could understand them, unlike some other resources I found…):
Aha! That [sorta] makes sense. I’m so used to writing code in dynamic languages that I have a hard time even figuring out what to Google when I get to something like this. Thanks for pointing me in the right direction!
Like answered before, the template argument needs to be declared constexpr or be a constant.
As a quick hack you can wrap it in a switch case statement. It defeats the purpose of the variadic template, but will compile and run.
If you want to learn how it can be used, have a look into the juce::dsp::ProcessorChain class. That one uses compile time loops which can be heavily optimised by the compiler.
To be perfectly honest, I cannot write such code. But thanks to block based processing you can get very far without.
Hey! There is a rather straightforward way to generate compile time assignments to tuple-like structures up to a constant highest index using templates and if constexpr. Here is an example to illustrate the idea. Not trying to win a code style beauty contest, but maybe it helps: