Is it possible to replace a long explicit list of initializers with the following template that generates it?
std::array<Foo, n_foos> foos = {{ {0, bar}, {1, bar}, {2, bar}, {3, bar}, {4, bar}, {5, bar}, {6, bar}, {7, bar}, }};
Now this code only works because we have constexpr int n_foos = 8 . How can this be done for arbitrary and large n_foos ?
source share