If I got this right, I could use it 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 1, ..., 100 and already know what during compilation? What is the most beautiful way to do this? Which is the most effective? Which is the shortest?
Edit: Of course, I could write a regular loop, but the actual use case would include more complex content than int s.
I simplified the example a bit.
source share