Compare elements in OwnedArray


Hi everyone,

I was trying to find elements with OwnedArray::contains() method and I realised that class OwnedArray compares pointers. Is there any way to compare elements using operator== when using OwnedArray?




No… the type of object that may be held in an OwnedArray doesn’t really tend to be the kind of thing that uses value semantics (plus, the array may contain null pointers). You’d have to do a quick routine yourself to do the comparison, using whatever null-pointer behaviour is appropriate for your class.

Or maybe your objects use value semantics, in which case an Array would probably be a better container for them?