I have the following snippet of code:
template <size_t N>
foo make() { ... }
...
for (...) {
auto foo = make<1>();
// lots of tests involving foo
}
I would like to repeat that latter block with different values for the non-type template parameter to make
, e.g., make<2>
, make<3>
, etc.
If this was a type I wanted to iterate over, I could use this solution, but it isn't clear that I can use non-type template parameters with a generic lambda in the same way.
How can I factor this so I can create run the block of code above but instantiating make
with different values for its non-type parameter. The solution should use only block-scope elements - this is easy if I can create some top-level template <size_t N> struct maker { ... }
object to wrap make
.