If I got that right I can use this to iterate over a fixed range:
for(int i: {1, 2, 3, 4, 5})
do_sth(i);
And this is the same thing:
vector<int> v{1, 2, 3, 4, 5};
for(int i: v)
do_sth(i);
But what if I want to iterate over the range of 1, ..., 100 and already know that at compile time? What is the most beautiful way to do that? What the most efficient? What the shortest?
Edit: of course I could write a regular for loop, but the actual use case would involve more complicated content than int
s.
I just oversimplified the example a bit.