Hi,
I would like to use range but without a for loop.
auto view_ = my_container | ::ranges::views::cycle | ::ranges::views::take( my_container.size() + 1 ) | ::ranges::views::drop( drop_count );
for ( auto &e : view_ ){/*do something*/; break; }
I would like to iterate "a la coroutine" my view manually as in view_() or something of the like.
That would give me the current value and increase the internal counter to the next element.
That would enable me to play with multiple views.
So, if my_container is vector<int> a{0,1,2,3}, I would have
view_(0); // 0 with starting offset, here 0
view_(); // 1 and so on taking the cycle into account
Right now, I have to recreate my view with a new drop_count value, which seems inefficient.
Hi, I would like to use range but without a for loop.
I would like to iterate "a la coroutine" my view manually as in
view_()
or something of the like. That would give me the current value and increase the internal counter to the next element.That would enable me to play with multiple views. So, if
my_container
isvector<int> a{0,1,2,3},
I would haveRight now, I have to recreate my view with a new drop_count value, which seems inefficient.
How to achieve that cleanly?
Thanks