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
.
t0m
September 7, 2017, 10:36am
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.
jimc
September 7, 2017, 11:41am
3
Don’t think you need boost any more.
You can probably modify this to make yourself a little wrapper.
Hey folks - would a range based for loop solution be nice for anyone else?
void func(ValueTree & tree)
{
for (auto & child: tree.children())
doSomething(child);
for (auto & property: tree.properties())
doSomethingElse(property);
}
And similarly for children of components and other important objects..?
t0m
September 7, 2017, 12:20pm
4
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.