Tidy reverse range-based for?


#1

Anybody here have a neat solution for iterating an OwnedArray and Array in reverse via range-based for loops?

Looks like Boost provides boost::adaptors::reverse, but we’re not using Boost…

And just thinking out loud - I believe this would require OwnedArray and Array to provide rbegin and rend.


#2

I think you could write your own iterator wrapping class that generates the required (modified) begin() and end(), but it’s not particularly simple.


#3

Don’t think you need boost any more.

You can probably modify this to make yourself a little wrapper.


#4

https://stackoverflow.com/questions/21510091/forauto-i-c-is-there-a-short-way-to-do-it-in-reverse-direction


#5

Indeed, I did search StackOverflow first. That’s where I realised Boost provided something to reverse iterate using range-based for, but JUCE does not.