I have a bunch of longish hand initialized arrays, e.g.:
const std::array<int, 16> a{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
const std::array<int, 16> b{16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31};
...
Is there a way for a more concise initialization, e.g. along these lines (illegal):
const std::array<int, 16> a{std::views::iota(0, 16)};
const std::array<int, 16> b{std::views::iota(16, 32)};
...
Yes there is. You can write a helper
make_array
as shown below.Demo