Copy Array of OwnedArray Pointers


#1

Hi,

Can anyone suggest a good way to get read-only access to a JUCE OwnedArray? That is, I would like an effective way to access/change the data pointed to but not allow changes to the OwnedArray itself.  A copy of the pointers seems like a starting place.  It might look something like this:

private:
OwnedArrray<class> things;

public:
Array<class*> getThingsCopy();

main:
Array<class*> temp = getThingsCopy();

// Do stuff

Perhaps, it would be better to return iterators, rather than a copy of all the pointers, each time?

 


#2

Why not just return a const reference to your OwnedArray? That's got zero overhead and the caller would be unable to alter it..


#3

Thanks! That sounds like the best way of doing it.