Feature request: OwnedArray::call


#1

Hello.

Apologies if this has been covered or I’m barking up the wrong tree, but would it be possible to implement an OwnedArray::call feature similar to ListenerList? To call all the objects within an OwnedArray, I either have to make a for loop, or have a separate ListenerList, and so would find this very usefull.

Thank you.


#2

If you can use c+±11 then it’s a one liner:

OwnedArray<MyObject> hey;

std::for_each (hey.begin(), hey.end(), [] (MyObject* obj) { obj->foo(); });

#3

Wow. Is that a lambda? They boggled me first time looking, maybe time to try again! Thank you.


#4

If you don’t like lambdas you can also write this without a lambda (it’s even shorter then):

OwnedArray<MyObject> array;

for (auto obj : array) obj->foo();

#5

Very nice, I think I’ve got some more advanced C++ to learn!