Array, OwnedArray indexOfSorted inconsistency


#1

Prototypes are different:

juce_OwnedArray.h

    template <typename ElementComparator>
    int indexOfSorted (ElementComparator& comparator, const ObjectClass* const objectToLookFor) const noexcept

juce_Array.h

    template <typename ElementComparator, typename TargetValueType>
    int indexOfSorted (ElementComparator& comparator, TargetValueType elementToLookFor) const

I’m trying to use OwnedArray::indexOfSorted with an ElementComparator declared like this:

    struct Compare
    {
      static int compareElements (Component* lhs, Handler* rhs)
      {
        return rhs->getComponent () - lhs;
      }
    };

#2

Yeah, I’m pretty sure I remember doing it like that deliberately because adding a template argument broke something.


#3

Ah yes, it had to do with ScopedPointer being passed in, the implicit conversion was not taking effect and the argument ended up as type ScopedPointer <>.

Any way to fix this?